Hello, I am trying to override the toString() method and then output an ArrayList to a JTextArea swing component. I will output the list to a gui using an action, but for the method itself, what should the return statement be? I am using return type String on the method, but I don't want to output to the command window. I understand part of the problem lies within incompatible types, but can I have a return of type ArrayList? Is there a generic return to use to satiate system so that I may append to JTextArea in the GUI?>
flowin 0
Newbie Poster
Recommended Answers
Jump to PostJust to add something to jon.kiparsky's good advice, each object has a toString method, whether it is overriden or not. Even the ArrayList.
If an ArrayList has String objects:ArrayList<String> list = new ArrayList<String>(); list.add("aaaa"); list.add("bbbb"); // They both do the same System.out.println(list); //or System.out.println(list.toString());
Then the …
All 2 Replies
jon.kiparsky 326
Posting Virtuoso
javaAddict 900
Nearly a Senior Poster Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.