File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes How to use ArrayList in jdk1.5 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Badass: Making Users Awesome this week in the Game Development forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to use ArrayList in jdk1.5" Watch "How to use ArrayList in jdk1.5" New topic

How to use ArrayList in jdk1.5

Pal Amutha

Joined: Jan 28, 2008
Posts: 13
import java.util.*;

public class myarraylist {

public static void main(String args[])
ArrayList ob1=new ArrayList();
//ArrayList<Alphabet> v=new ArrayList<Alphabet>();


In the above code , it gives warning message.
I refer through net. They used generic. see the comment line.
they mentioned like this way.

the general syntax is :
ArrayList<E> object=new ArrayList<E>();
here , what is E denote. Please explain it
Kaydell Leavitt
Ranch Hand

Joined: Nov 18, 2006
Posts: 689

Welcome Pal Amutha,

Where is the class: Alphabet defined?
Henry Wong

Joined: Sep 28, 2004
Posts: 19495

Even if the Alphabet class is defined somewhere, it is moot. The example uses String objects, not Alphabet objects.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3370

Yes, that is true. As Henry said, the actual type being provided is of type String. So no matter what class you gave, it will complain because of a type mismatch.

Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3370

Originally posted by Pal Amutha:
here , what is E denote.

E denotes an Element, as a general shortcut they represent it in a single letter in caps. K for key, V for value etc.,
I agree. Here's the link:
subject: How to use ArrayList in jdk1.5