Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!




Results 1 to 1 of 1

Thread: Understanding how an ObservableList works

  1. #1
    Junior Member
    Join Date
    May 2013
    Thanked 0 Times in 0 Posts

    Default Understanding how an ObservableList works

    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


    (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?
    Last edited by TiJuan; June 6th, 2013 at 08:03 PM. Reason: typo

Similar Threads

  1. Inserting data from ObservableList to MySQL database
    By TiJuan in forum JDBC & Databases
    Replies: 0
    Last Post: June 2nd, 2013, 11:16 AM
  2. how this code works?
    By vigneshwaran in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 11th, 2012, 08:18 AM
  3. This Works In My Other Code But Not This One?
    By Ooogel in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 5th, 2012, 05:49 PM
  4. how array works ?
    By erdy_rezki in forum Java Theory & Questions
    Replies: 4
    Last Post: May 1st, 2012, 09:57 AM
  5. GUI Only Works Sometimes
    By bgd223 in forum What's Wrong With My Code?
    Replies: 7
    Last Post: July 12th, 2011, 08:08 AM

Tags for this Thread