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 8680965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:22:59+00:00 2026-06-12T21:22:59+00:00

I’m trying to Display individual elements of an Object I have created. It is

  • 0

I’m trying to Display individual elements of an Object I have created.

It is a simple Java program that allows users to add and keep track of Player Details.

I’m just stumped when it comes to displaying the details after they have been added already. here is what my code looks like

I can create the object and input it into the arraylist no problem using the case 2, but when I try to print it out I want to do something like

System.out.println("Player Name" + myPlayersArrayList.PlayerName + "Player Position" + myPlayerArrayList.PlayerPosition + "Player Age" + "Player Age");

I know that is not correct, but I dont really know what to do, if anyone can be of any help it would be greatly appreciated. Thanks

System.out.println("Welcome to the Football Player database");
 System.out.print(System.getProperty("line.separator"));


     UserInput myFirstUserInput = new UserInput();
    int selection;
            ArrayList<Player> myPlayersArrayList = new ArrayList<Player>();

            while (true) {

                System.out.println("1. View The Players");
                System.out.println("2. Add A Player");
                System.out.println("3. Edit A Player");
                System.out.println("4. Delete A Player");
                System.out.println("5. Exit ") ;
                System.out.print(System.getProperty("line.separator"));

                selection = myFirstUserInput.getInt("Please select an option");
                System.out.print(System.getProperty("line.separator"));
                switch(selection){


        case 1: 

                        if (myPlayersArrayList.isEmpty())
                                    {
                        System.out.println("No Players Have Been Entered Yet");
                        System.out.print(System.getProperty("line.separator"));
                        break;}

                        else 
                        {for(int i = 0; i < myPlayersArrayList.size(); i++){
                            System.out.println(myPlayersArrayList);

        }
                    break;

                    case 2:  {

                        String playerName,playerPos;
                        int playerAge;

                                playerName = (myFirstUserInput.getString("Enter Player name"));
                                playerPos = (myFirstUserInput.getString("Enter Player Position"));
                                playerAge = (myFirstUserInput.getInt("Enter Player Age"));   

                                myPlayersArrayList.add(new Player(playerName, playerPos, playerAge));   ;
                                                        break;
                    }
  • 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-12T21:23:01+00:00Added an answer on June 12, 2026 at 9:23 pm

    You need to use index to access individual element: –

    for(int i = 0; i < myPlayersArrayList.size(); i++){
        System.out.println(myPlayersArrayList.get(i));
    }
    

    Then you can override toString() method in your Player class

    public String toString() {
        return playerName + " : " + playerAge + " : " + playerPosition;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I have just tried to save a simple *.rtf file with some websites and
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I have thousands of HTML files to process using Groovy/Java and I need to
I am trying to loop through a bunch of documents I have to put

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.