Results 1 to 3 of 3
  1. #1
    Louis is offline Member
    Join Date
    Nov 2010
    Posts
    9
    Rep Power
    0

    Default A private static ArrayList hold an object and static getter ArrayList

    A private static ArrayList named list that holds a list of Student objects.

    ArrayList<student> list = new ArrayList<Student>();

    A static getter named getList() that returns the ArrayList.

    public static ArrayList<Student> getList() {
    return list;
    }

    My arraylist and getlist are declare correctly ??
    Why my output become like this "assign_student.Student@c17164, assign_student.Student@1fb8ee3"??
    Last edited by Louis; 11-16-2010 at 07:18 PM.

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    6

    Default

    because your Student class does not override the toString method!

    Writing toString Methods & Tech Days : Core Java Technologies Tech Tips

  3. #3
    Louis is offline Member
    Join Date
    Nov 2010
    Posts
    9
    Rep Power
    0

Similar Threads

  1. One big arraylist and static mess
    By Crypts in forum New To Java
    Replies: 12
    Last Post: 05-21-2010, 02:23 PM
  2. Arraylist errors with private fields
    By DJRome in forum New To Java
    Replies: 5
    Last Post: 03-02-2010, 12:00 PM
  3. private static setter method problem
    By kyussy in forum New To Java
    Replies: 7
    Last Post: 01-27-2010, 04:02 PM
  4. Replies: 1
    Last Post: 08-07-2007, 05:05 AM
  5. Replies: 1
    Last Post: 08-01-2007, 09:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •