Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7569121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:05:41+00:00 2026-05-30T15:05:41+00:00

I have an array list of Fleets (Each fleet will hold its own list

  • 0

I have an array list of Fleets (Each fleet will hold its own list of Trucks).

I have a fleet class with the constructor

public Fleet(String businessName){
    this.businessName = businessName;
    this.fleetList = new ArrayList<Truck>();
}

So:

In my TUI, I have a helper method called createFleet. When the user presses 1 on the menu, it asks for a name of his business, and then makes a fleet named that. That method is:

public static void createFleet(){
    System.out.println("");
    System.out.println("Please enter the name of the fleet.");
    inputText = scan.nextLine();

    fleetCollection.add(new Fleet(inputText));
    printFleets();
    System.out.println("");
    System.out.println("--- Fleet: " + inputText + " added ---");
    System.out.println("");
}

And my problem is that when I add one Fleet, and print the results I get:

Fleet 0: Fleet Number One

But when I add Fleet Number One, then press 1 on the menu again to add ANOTHER fleet (named Fleet Number Two) and print the fleet list, the results are:

Fleet 0: Fleet Number Two
Fleet 1: Fleet Number Two

It seems to be confusing the two…and this further breaks the program when I try to add trucks to the fleet, because It cannot pick the “right” fleet.

Please let me know if you need any other of my code.
I just need this to correctly add and print the fleets in the fleet list:

private static ArrayList<Fleet> fleetCollection;

Thank you 🙂 for all the help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T15:05:42+00:00Added an answer on May 30, 2026 at 3:05 pm

    You probably declared businessName in Fleet class static, if so then remove it

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In FleetTUI.java I have a list of Fleets (Each fleet will hold its own
I have an array list containing objects from the class EventOnMap . Every object
Let's say I have an array list of objects, and each object has the
I have an array list that could contain component or composite and each component
I have an Array list of a custom class which is essentially has two
I have an array list comprised of Objects. Each object is comprised of Strings.
I have an array list in my class and am getting the value for
I have an array list ArrayList<String> firstname; In this I am storing n number
i have an array list of custom objects. each object contains a value i
I have hashtbles in array list. List<Hashtable<String, String>> info = new ArrayList<Hashtable<String, String>>(); Hashtable<String,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.