Templated Lists in Java

Posted on 2006-05-04
Last Modified: 2010-03-31
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.
Question by:Linky
    LVL 86

    Accepted Solution

    List<MyClass> = new ArrayList<MyClass>();

    LVL 14

    Assisted Solution

    ArrayList<MyClass> al = new ArrayList<MyClass>();

    and that's it
    LVL 2

    Author Comment

    Thank you both for the speedy response.
    LVL 86

    Expert Comment


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
    By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
    Video by: Michael
    Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
    Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now