This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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: 689

Welcome Pal Amutha,

Where is the class: Alphabet defined?
Henry Wong

Joined: Sep 28, 2004
Posts: 20050

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

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

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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: How to use ArrayList in jdk1.5
It's not a secret anymore!