This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes ArrayList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "ArrayList" Watch "ArrayList" New topic
Author

ArrayList

renu richard
Ranch Hand

Joined: Oct 06, 2008
Posts: 116
Hi,
is there something like this


Cheers,
Richard
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
Yes, the declaration of an ArrayList looks something like that.

Justin


You down with OOP? Yeah you know me!
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Hi Renu,

I think what you're asking is whether you can use a primitive like "int" as a generic type parameter to a class. The answer is no, you can't; Java doesn't support that.


[Jess in Action][AskingGoodQuestions]
Balagopal Kannampallil
Ranch Hand

Joined: Oct 18, 2004
Posts: 136

Hi,

One can only use reference types as the Type argument while using generics. You can make your own generic classes but cannot use primitives as Type arguments. You can use their wrappers as Type arguments and put the primitives directly into the ArrayList with the help of autoboxing.


SCJP 5.0 and now fighting with ExtJS
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ArrayList
 
Similar Threads
Difference between ArrayList<int> and ArrayList<Integer>
While working from Head first java, I came across this problem... Please help
Error: Generics are not supported in -source 1.4
jstl-el problem
[newbie] Vector of arrays...how to add them