This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori 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 OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
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: 24193

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
It's not a secret anymore!