i´m working on a project that involves many classes and a lot of objects….i have a class(main) that save objects into a linked list, later other classes(main too) will show the attributes of any object saved in the linked list acording the user needs. i want to know how do i share the objects saved in the first main class to other classes…then modify the list in other class and update the list as well..
This is the code when i add objects to the linked list…
LinkedList list = new LinkedList();
int i;
i=(combo.getSelectionIndex());
problema.setUsuario(combo.getItem(i));
problema.setLugar(text.getText());
problema.setCodigoequipo(text_3.getText());
lista.add(problema);//the adding
shell.close();
later… when i´m consulting the objects in other class i need to show some attributes of them.
i’ll appreciate your answers 🙂
The linked list has references to all the objects it contains. In order to share the objects, you only need to pass a reference to the linked list.