I tell you that I have two classes, a class of Task type and another of type Person, within the attributes of type person, has an ArrayList of Task type, when I create an object of Task type, and when filling this object with its attributes.
public class Persona {
private String nombre;
private String apellido;
private String clave;
private String usuario;
private ArrayList<Tareas> tareaTrabajo;
What I want is to add to the object of type person, more objects in your ArrayList of Task type.
example:
Tarea jugar=new Tarea("pc", "Sims");
Tarea dormir=new Tarea("Casa","2 horas");
ArrayList<Tarea> misTareas=new ArrayList<Tarea>();
misTareas.add(jugar);
misTareas.add(dormir)
Usuario user1=new Usuario("usuario 1", "Javier", "Gallardo", "Informatica","123",misTareas);
// Attempt 1: I get an error
Tarea trabajar=new Tarea("cine","7 horas");
user1.getTareaTrabajo().add(trabajar);
// Attempt 2: replace everything saved by the newly created ArrayList
Tarea viajar=new Tarea(". . . ",". . . ");
ArrayList<Tareas>tarea1=new ArrayList<>();
tarea1.add(viajar);
user1.setTareaTrabajo(tarea1);
I hope for your help.