File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "ArrayList" Watch "ArrayList" New topic


renu richard
Ranch Hand

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

Justin Fox
Ranch Hand

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


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

Joined: Jul 08, 2003
Posts: 24199

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


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:
subject: ArrayList
jQuery in Action, 3rd edition