1. Why are wrapper objects (to primitive data types) immutable? coderanch.comWelcome to JavaRanch. The reason why your code doesn't work has nothing to do with immutability. If you would have used int instead of Integer, you would have gotten the same result. Your code does not produce the output you expect because Java passes arguments to methods by value - which means, if you pass a variable to a method, only ... |
2. Why are all primitive wrappers immutable? |
3. Time to revisit the primitive immutable wrapper objects in the java.lang package? coderanch.comIs it time to revisit the primitive wrapper objects in the java.lang package? I think Java's early attempts at object wrappers aren't ideal and lead to arguments about when to use objects vs primitives. Primitive types always win out over objects because of their speed, changeability, and lower memory requirements. Of course this argument misses the point entirely, especially because often ... |
4. getting/setting values for Immutable primitive wrappers forums.oracle.comi have two objects. i need to share an Integer value between then. borh need to be able to increase/decrease the integer value. java.lang.Integer is immutable.... so, my ultra-lame solution is to pass a Collection and add/remove objects. and the use the "size" of the collection as my integer value. is there a better way? basic code: .... Integer intObj = ... |