Jump to content

Talk:Primitive wrapper class in Java

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Other languages

[edit]

Is Java the only language using wrapper classes, or some sort of? -- Face 08:30, 31 October 2006 (UTC)[reply]

No, but it is the only language I know of that has primitive wrappers as part of the standard library/language. The distinction here is that the wrapper classes are to 'wrap' the non-object primitive types in an object so that every type can be treated generically as an object. —Doug Bell talkcontrib 09:59, 31 October 2006 (UTC)[reply]
Objective-C (Cocoa framework) has a NSValue class whose purpose is to wrap any non-object datatype, like C primitive types, C pointers, C structs, etc. into an Objective-C object. --206.72.77.76 (talk) 00:23, 31 March 2009 (UTC)[reply]

Non-primitive Wrappers

[edit]

It's my understanding that wrapper classes need not refer specifically to the case of primitive wrappers, and for that matter they need not be specific to Java. I believe that in general wrappers can be used to add additional layers of encapsulation, but I came here hoping for a better definition only to find that Wrapper class redirected here. Shouldn't there be a separate page for wrapper classes in general, or at least something to indicate that not all wrappers are primitive wrappers? Mickeyg13 (talk) 22:59, 24 February 2009 (UTC)[reply]

Perhaps should Wrapper class redirect to a disambig page the points here as well as to the page for the Wrapper pattern? Presently it links directly here but "wrapper class" may reference the design pattern instead of the Java feature. Thoughts? Mickeyg13 (talk) 20:49, 25 March 2009 (UTC)[reply]

I know this is later, but I wholeheartedly agree. I was really surprised to end here when looking up wrapper classes and I'm even more shocked that nothing has been done to fix the problem since it was pointed out in 2009. Whatever you do, I'm probably not interested. (talk) 16:58, 5 January 2023 (UTC)[reply]

Memory consumption

[edit]

The article should mention that there is a significant difference between primitives and their wrapper objects when it comes to memory consumption. Although this might not be part of the Java language specification, in real life JVMs an Integer object requires typically several times as much heap space compared to a primitive int. Depending on the scenario this can have a big impact on runtime performance, heap size and also garbage collection. 192.157.11.100 (talk) 11:18, 27 October 2017 (UTC)[reply]