Welcome to the Java Programming Forums

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

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Need help to implement a solution with ArrayLists & Objects

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Thanked 0 Times in 0 Posts

    Default Need help to implement a solution with ArrayLists & Objects

    Here's the premise of what I'm trying to do.

    I need to write some code that will allow a user to add stops to a route between two places.

    For example, a person is travelling from Place A to Place B via a public bus and would like to know at which places the bus is going to stop during the route.

    Now an Admin user should be able to add stops within a route and there are multiple places which means multiple routes (Place A to B, A to C, B to D, D to C, etc).

    I know that for a route I will need to create an ArrayList which will hold all of the stops but the issue I'm having is figuring out how to create a new ArrayList for each route.

    In the program, the user will input their start place and then their end place and any stops will be returned. For an Admin user, they will also input a start place and end place but then add stops so when a regular user checks a route between two places, stop that have been added will be displayed.

    Any ideas of how I could implement this?

    Like I said, I know that I will need ArrayLists but I am not sure how to implement this for multiple routes created on the fly.

  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Thanked 827 Times in 770 Posts
    Blog Entries

    Default Re: Need help to implement a solution with ArrayLists & Objects

    Sounds like the job for a Graph data structure.
    Graph (abstract data type) - Wikipedia, the free encyclopedia

Similar Threads

  1. exercise solution ???
    By somebodyonearth in forum Java Theory & Questions
    Replies: 1
    Last Post: March 11th, 2012, 12:52 PM
  2. [SOLVED] ArrayLists - Getting index of parameters of objects of ArrayLists.
    By mwebb in forum Object Oriented Programming
    Replies: 1
    Last Post: February 16th, 2012, 06:39 PM
  3. Java solution required
    By javabeginer in forum Java Theory & Questions
    Replies: 15
    Last Post: February 6th, 2012, 04:58 PM
  4. Solution
    By Suresh.athi in forum The Cafe
    Replies: 1
    Last Post: January 19th, 2012, 07:46 AM
  5. Please help me with the solution
    By abhyudayaupadhyay in forum What's Wrong With My Code?
    Replies: 0
    Last Post: July 6th, 2011, 03:21 PM