This is possibly a simple problem but I am having issues. I have 3 classes. A Student class that contains a setmethod:
public boolean setName(String fname)
{
this.name = fname;
return true;
}
A TestClass with a main that passes a string to the setmethod
static Student action;
public static void main(String[] args)
{
action.setName("John");
}
and a Classroom class that contains an add student method.
public boolean add(Student newStudent)
{
???
return true;
}
I know how to create and add an object to an array list but I am confused as to how to do it using 3 separate classes. My array list init is:
List<Student> studentList = new ArrayList<Student>();
How would I associate the attributes(name in this case) being set in the Student class to a new object being created in the Classroom class?