Can someone please help me understand what Java is doing? I've made an ObservableList named data. I add elements to the list, something like this:
data.add(new ClientList(LastName, FirstName, Street, City, State, Zip, Telephone, DateOfBirth);
So I make a form for adding people to this list, which is held in Java's memory so I can later click a button to add, let's say 5 people to my database. My first question is:
1) Would I be correctly describing this as a list of 5 objects, with each object containing 8 values? If not, what would be the proper way, using Java terminology, to describe what has been done here?
Now, given that I have this above ObservableList called data, if I put in the command
System.out.println(data.toString())
(and assuming I have 5 clients in my list) I would get a list of 5 objects referenced on my screen (albeit only the pointer to their "slot" in memory), correct? Up to this point, I'm really hoping people will either say I'm correct, or tell me my terminology is all wrong and should be [insert correct terminology here]. Or if I'm just way off base, please correct that, too.
Now what I don't understand is, if I write the following code:
for (Object o : data) { [variable] = data.get(0); }
the integer (0) seems to refer to the object in the list indexed at 0 (which would be all of the values for the first person in the list, right?). NetBeans wants me to make the variable a type "Object" for this, and anything else I put there either gives me a compile error or a runtime error, depending on how I write the statement.
But since I'm iterating over the list, I thought this integer was supposed to point to the first value (in my case, LastName) in the object currently being handled by the for loop. From what I can deduce from how my code runs, I am incorrect, and the previous paragraph is what is going on. How, then, can I read the values for each object in my list?