• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 177
  • Last Modified:

Templated Lists in Java

say i have a class:

public class MyClass implements Serializable
{
    String name;
    Integer x;

.... some constructors

... some accessors

}

In Java 1.5 How do I make a templated list to holds MyClass? I need to add MyClass objects, etc...

So its List<MyClass> = ....... // I dont know how to setup this semester.

Code would help.
0
Linky
Asked:
Linky
  • 2
2 Solutions
 
CEHJCommented:
List<MyClass> = new ArrayList<MyClass>();

(e.g.)
0
 
StillUnAwareCommented:
ArrayList<MyClass> al = new ArrayList<MyClass>();

and that's it
0
 
LinkyAuthor Commented:
Thank you both for the speedy response.
0
 
CEHJCommented:
:-)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now