How do i make an Arraylist

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nomad
    Recognized Expert Contributor
    • Mar 2007
    • 664

    How do i make an Arraylist

    Hello everyone:
    Need some help on Arraylist.

    I made a array and I'm a little confused on how to make the Arraylist. Do I need to make an Arraylist for each of the following or do I just add this below

    ArrayList<Emplo yeeClass> arlist = new ArrayList<Emplo yeeClass >();
    here is part of my code.

    Code:
    class EmployeeClassa {
        private String empid;
        private String lname;
        private String fname;
        private String street;
        private String city;
        private String zip;
        private int yearsworked;
        private double payrate;
        public EmployeeClassa (String id) {
        		empid = id;
        }
    thanks nomad
    PS the book I'm using is not to good It's called "Big Java"
  • horace1
    Recognized Expert Top Contributor
    • Nov 2006
    • 1510

    #2
    yes
    Code:
    ArrayList<EmployeeClass> arlist = new ArrayList<EmployeeClass >();
    should be OK but is the class called EmployeeClass or EmployeeClassa ?

    Comment

    • nomad
      Recognized Expert Contributor
      • Mar 2007
      • 664

      #3
      It should be EmployeeClassa

      I change it so one could understand it better
      private List<EmployeeCl ass> arlist = new ArrayList<Emplo yeeClass>();

      does this work?
      nomad

      Comment

      • horace1
        Recognized Expert Top Contributor
        • Nov 2006
        • 1510

        #4
        Originally posted by nomad
        It should be EmployeeClassa

        I change it so one could understand it better
        private List<EmployeeCl ass> arlist = new ArrayList<Emplo yeeClass>();

        does this work?
        nomad
        get the names the same
        Code:
        ArrayList<EmployeeClassa> arlist = new ArrayList<EmployeeClassa >();
        and it should work

        Comment

        • nomad
          Recognized Expert Contributor
          • Mar 2007
          • 664

          #5
          Originally posted by horace1
          get the names the same
          Code:
          ArrayList<EmployeeClassa> arlist = new ArrayList<EmployeeClassa >();
          and it should work

          Thanks Horace1

          Comment

          • Ganon11
            Recognized Expert Specialist
            • Oct 2006
            • 3651

            #6
            Originally posted by nomad
            PS the book I'm using is not to good It's called "Big Java"
            Whatchootalkinb out!? I learned Java on that book. It was great!

            Comment

            • nomad
              Recognized Expert Contributor
              • Mar 2007
              • 664

              #7
              Originally posted by Ganon11
              Whatchootalkinb out!? I learned Java on that book. It was great!
              Myself I learn from examples better. The Book is ok but I get more inportant info from sites like this

              Comment

              • Ganon11
                Recognized Expert Specialist
                • Oct 2006
                • 3651

                #8
                Originally posted by nomad
                Myself I learn from examples better. The Book is ok but I get more inportant info from sites like this
                :) Whatever way it takes for you to learn.

                Comment

                Working...