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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:10:53+00:00 2026-06-03T02:10:53+00:00

I have an ArrayList of objects (A class called OrderItem). OrderItem has a toString()

  • 0

I have an ArrayList of objects (A class called OrderItem). OrderItem has a toString() method in it.

I also have a GUI class in which I have a JList. I want to list all the toString()’s for the elements of the arrayLists.

I know that for an arrayList of strings you can make them show in a JList by using:

ArrayList<String> myArrayList  = new ArrayList<String>();
myArrayList.add("Value1");
myArrayList.add("Value2");
myJList = new JList(myArrayList.toArray());

But I want to list the toString() methods of an object arrayList, i.e. have something like:

ArrayList<OrderItem> myArrayList  = new ArrayList<OrderItem>();
myJList = new JList(myArrayList.toString());

I realise that there is a possibility that JList doesn’t support such a feature or that there is some sort of logic problem with this. If that is so could you inform me as to why? Because surely an arrayList of strings should work in a similar way to an object arrayList’s toString(). I merely want to be pulling out a String value for the elements and using those values for my list.

I’ve searched the web for an answer and have not been able to find one that helps me, so I’ve come here to try to get this resolved.

Thanks a lot!

  • 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-03T02:10:54+00:00Added an answer on June 3, 2026 at 2:10 am

    By default, JList shows the toString value of the object. So there is no need to convert your objects to strings.

    You can override that behavior of JList if needed by creating custom cell renderers. See How to Use Lists for more details.

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

Sidebar

Related Questions

Basically, I have a Container class called Employees which has in it an ArrayList.
At the moment inside the class I have ArrayList which the objects are stored
I made a class called SpecializationBean which has two private fields: private ArrayList<SelectItem> specializationItems=
I have an arraylist called 'pri1', I want this array list to be available
I have an arraylist of objects in my servlet where I want to call
I have an ArrayList that I want to use to hold RaceCar objects that
Ok, so I have an ArrayList (arrBok) , which is full of book objects
I have an array list of objects in my application. private static ArrayList<Player> userList=new
I have a base class called Geometry from which there exists a subclass Sphere
In short, I have an object called PersonList that has a List of Person

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.