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
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: 688

Welcome Pal Amutha,

Where is the class: Alphabet defined?
Henry Wong

Joined: Sep 28, 2004
Posts: 18117

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: 3344

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: 3344

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.,
wood burning stoves
subject: How to use ArrayList in jdk1.5
Similar Threads
sorting a vector
Don't understand C++ Iterators and Vectors
Copying from Vector to Array: any inbuilt java method available like List.addAll(Vector)
where will be the method implementation present for an interface?
Vector with bean:write tag