So here is my methods:
public static ArrayList collectSchedule(ArrayList schedule, ArrayList list, int counter)
{
((ArrayList) list.get(counter)).add(schedule);
System.out.println(list);
return list;
}
public static ArrayList getClassInfo(int count)
{
Scanner stdIn = new Scanner (System.in);
String userInput;
System.out.print("Enter the name of class #" + count + " : ");
userInput = stdIn.nextLine();
ArrayList x = getClassTime();
x.add(0, userInput);
x.add(1, getClassLength());
x.add(2, getDayOfTheWeek());
return x;
}
So I take the value "x" from getClassInfo (which is an ArrayList) and input that into the method collectSchedule along with a number (the index of where I want it) and another ArrayList (lets call it "schedule"). I add "x" (the ArrayList) to the ArrayList "schedule". If I print out "x" it will show all values of "schedule". (note: I add multiple different instances of "x" to schedule!). So if I add 3 different "x's" to "schedule", it will print them all out separately ( [x, x, x][x, x, x][x, x, x] ). I'm having troubles getting only a single value of "x" from "schedule".
I thought this code would work but it gives me an error at compilation.
public static void creation(ArrayList list)
{
System.out.println((schedule.get(0)).x().get(1));
}
Can anyone help me where I've gone wrong? I read something about using an object? But not sure how!
Thanks!