This discussion is archived
2 Replies Latest reply: Jul 2, 2012 7:42 AM by 946867 RSS

ArrayList lost it's data

946867 Newbie
Currently Being Moderated
Hi, my situation is,
I have an ArrayList that lost it's data when its populate by a property List from a singleton class.

More detailed :*

I have a private variable (hostelCategoryList in Agenda singleton class :
List<Category> hostelCategoryList = new ArrayList<Category>(); // it's have getter and setter

In static void main class, I call my agenda singleton instance :
Agenda agenda = Agenda.getInstance();

I want to put a List<Category> in my hostelCategoryList (My List<Category> is in a CategoryCatalog singleton class) :

CategoryCatalog categoryCatalog = CategoryCatalog.getInstance();
agenda.setHostelCategoryList( categoryCatalog.getCategoryList() );

later... my hostelCategoryList is empty...

Suprisely, if I put a List<Category> like this, it's work :

List<Category> categoryList = new ArrayList<Category>();
categoryList.add(new Category);

agenda.setHostelCategoryList( categoryList );

// It's work ! Later, my hostelCategoryList is not empty !

Whats the problem ?

Thank you very much to look my code.

Francis G-Tessier


  • Correct Answers - 10 points
  • Helpful Answers - 5 points