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

  • SEARCH
  • Home
  • 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 8928427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:26:03+00:00 2026-06-15T08:26:03+00:00

I have an ArrayList that contains Objects. What I have been wanting/needing to do

  • 0

I have an ArrayList that contains Objects. What I have been wanting/needing to do is search for a specific Object within the ArrayList and alter one of it’s values if found. I.E. I have a team of Football Players, say Philadelphia Eagles that contains the team name, total points scored total sacks, and then lists all the players by first name, last name, games played, and position. I am looking for a specific player say Chad Hall and I want to remove him from the Eagles and trade him to the New England Patriots. What I have so far is the iteration of the ArrayList but my code isn’t finding the player and then exits out.

case 6:
           String name = "";
           System.out.print("Who would you like to trade? ");
           name = kb.nextLine();
           tradePlayer(nflTeams, name);

public static void tradePlayer(ArrayList<Team> nflTeams, String name)
  {
     Scanner kb = new Scanner(System.in);
     String teamName = "";
     System.out.print("What team do you want to trade this player to?(Team Acronym) "    );
     teamName = kb.nextLine();

     for(Team t: nflTeams){
        if (nflTeams.contains(name.toLowerCase()))
                      t.setName(teamName);
                }
     System.out.println("Cannot find " + name);
  }

The Player class involved constructed players by firstname, lastname, team, position, played. What I want to alter is the team. In the Team class I have the setName(String) to set team names.

Any suggestions or thoughts are much appreciated.

  • 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-06-15T08:26:04+00:00Added an answer on June 15, 2026 at 8:26 am

    if (nflTeams.contains(name.toLowerCase()))

    What are you trying to do? Your list nflTeams contains Team objects not names.
    This can not work.
    If you need to access a Team via its name then use Map<String,Team> instead

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

Sidebar

Related Questions

I have an ArrayList that contains objects. (this objects are clases, every object contains
I have a two-dimension ArrayList that contains double values: ArrayList<ArrayList<Double>> data = new ArrayList<ArrayList<Double>>();
I have an arraylist, that contains model class objects. Here is how I create
I have an object that contains a list of other objects. Say it's as
For simplicity, say I have an ArrayList that contains objects of type A, B
I have a search function that returns an arraylist of objects to my form.
I have an arraylist that gets different type of values in it, 1st value->
I have an ArrayList that I want to use to hold RaceCar objects that
I have a byte[] that i obtained using Object ArrayList<Obj> Can anyone tell me
I have an ArrayList containing Objects that have a date value. Now I want

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.