Results 1 to 7 of 7
  1. #1
    sebjavierw is offline Member
    Join Date
    May 2013
    Posts
    6
    Rep Power
    0

    Default Java Linked Lists

    I have been given the task of making a time zone converter.

    Note: We are restricted to using AWT
    My plan is to use two lists side-by-side to let the user choose the location
    The first list is the region eg. Europe, Asia, Pacific etc..
    The second list is the city eg. Paris, London, Hong Kong, Melbourne etc...

    I am wondering how I would go about 'linking' the lists together so that only the Europe cities appear when the Europe option is selected.

    Thanks for any help

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,539
    Blog Entries
    7
    Rep Power
    20

    Default Re: Java Linked Lists

    Use a Map<String, List<String>> instead; it maps a region to a list of cities.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    sebjavierw is offline Member
    Join Date
    May 2013
    Posts
    6
    Rep Power
    0

    Default Re: Java Linked Lists

    Ok thanks heaps
    I will give it a go

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,539
    Blog Entries
    7
    Rep Power
    20

    Default Re: Java Linked Lists

    On second thought, I'd make it a Map<String, Map<String, TZInfo>> where a region maps to another map that maps a city to a TZInfo object (whatever that contains).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    sebjavierw is offline Member
    Join Date
    May 2013
    Posts
    6
    Rep Power
    0

    Default Re: Java Linked Lists

    I am referencing the cities and regions from an external .csv file.

    I am also wondering how would you read the .csv file into an arraylist for the said lists?

    Thanks

  6. #6
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,539
    Blog Entries
    7
    Rep Power
    20

    Default Re: Java Linked Lists

    Quote Originally Posted by sebjavierw View Post
    I am referencing the cities and regions from an external .csv file.

    I am also wondering how would you read the .csv file into an arraylist for the said lists?

    Thanks
    Have a look at the String.split( ... ) method.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  7. #7
    sebjavierw is offline Member
    Join Date
    May 2013
    Posts
    6
    Rep Power
    0

    Default Re: Java Linked Lists

    Quote Originally Posted by JosAH View Post
    On second thought, I'd make it a Map<String, Map<String, TZInfo>> where a region maps to another map that maps a city to a TZInfo object (whatever that contains).

    kind regards,

    Jos
    Sorry but could you explain this a bit further if possible?

Similar Threads

  1. help with linked lists
    By akusa in forum New To Java
    Replies: 1
    Last Post: 04-15-2013, 04:34 AM
  2. Linked Lists
    By ashplusham in forum New To Java
    Replies: 3
    Last Post: 11-20-2012, 08:05 PM
  3. VERY new to Java, need help with linked lists?
    By seven in forum New To Java
    Replies: 2
    Last Post: 02-29-2012, 02:56 AM
  4. Copy or Clone java Linked Lists
    By koko99 in forum AWT / Swing
    Replies: 1
    Last Post: 04-28-2011, 03:07 AM
  5. Linked Lists
    By Dee in forum New To Java
    Replies: 18
    Last Post: 02-02-2011, 03:14 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •