3 ms·
Instead of "Codes like a class, works like an int!" they probably meant "Codes like a class, works like a struct". The fact that a final class cannot be repres
by rurban 13y ago
Instead of "Codes like a class, works like an int!" they probably meant "Codes like a class, works like a struct".
The fact that a final class cannot be represented and optimized to a simple struct in a non-dynamic language is really disturbing.
- aardvark179 13y agoNo, they did mean, "like an int." in that value types in java are intended to be atomic and immutable in the same way primitives types already are and that structs (in many languages) aren't.
- mcosta 13y agoIt is not. Java dinamic as runtime (if that means something) but is statically typed. Java is dinamic in some ways, arrays have not declared size, has reflection and dinamic method dispatch, but all clasess and are declared and required. A final class can be represented as a simple (plain) struct if the scape analysis tells so, and allocated on the stack. Else, that inmutable object can be used as a lock, inserted into a collection (think hash) or whatever you can do with an object.