File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes AutoBoxing in Collections Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "AutoBoxing in Collections" Watch "AutoBoxing in Collections" New topic
Author

AutoBoxing in Collections

Jart Bo
Ranch Hand

Joined: Oct 22, 2007
Posts: 144



Hi Guys,

I just wanted to confirm. This compiles so in any type of legacy collection, primitives are going to be autoboxed right? Thanks!

[ May 13, 2008: Message edited by: Jart Bo ]
[ May 13, 2008: Message edited by: Jart Bo ]

SCJP, SCWCD
Sunny Jain
Ranch Hand

Joined: Jul 23, 2007
Posts: 433

Hi Bo,

I think you can yourself compile this code and see anyway i think it will work.I don't find any problem with that.


Thanks and Regards,
SCJP 1.5 (90%), SCWCD 1.5 (85%), The Jovial Java, java.util.concurrent tutorial
sridhar row
Ranch Hand

Joined: Jan 16, 2008
Posts: 162
Hi Jart Bo,

It will work as long as it is Java 5. Prior to Java 5 there was no Autoboxing feature so probably give a compiler error.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13875
    
  10

Originally posted by Jart Bo:
I just wanted to confirm. This compiles so in any type of legacy collection, primitives are going to be autoboxed right?

What is normally meant by a "legacy collection" is one of the old collection classes (such as Vector or Hashtable), from Java 1.1, before the collections framework was added.

But I guess here you mean a collection without using generics.

Yes, primitive values will be autoboxed, also when using a collection without generics.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: AutoBoxing in Collections
 
Similar Threads
How many String are created??
Wrapper class
cleared SCJP but scored only 63%, is that score respectable or not
Failed SCJP 6
Passed SCJP 6