File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ArryList of Objects

 
manikandan jayakumar
Ranch Hand
Posts: 44
Firefox Browser Tomcat Server VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

i want to display arraylist of object can anyone help me?




testClass.java is in /test/




'm not able to display the list. 'm getting test.testObject@....
like this?

How to get the correct values?


Thanks in advance
 
Mohamed Sanaulla
Saloon Keeper
Pie
Posts: 3159
33
Google App Engine Java Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
manikandan jayakumar wrote:
...

'm not able to display the list. 'm getting test.testObject@....
like this?
...

Please UseRealWords - Words like 'm are not understood by all

manikandan jayakumar wrote: getting test.testObject@....
like this?

Coming back to the query-
You have to override the toString method in your testObject class.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you pass an arbitrary object to System.out.println, as you are doing in lines 9 and 11, Java will call the toString method on that object and print the string that that method returns.

If you do not implement your own toString method in the class of the object, then the default toString method of class Object will be used, and it will print a string that looks like: classname@hexcharacters

So, if you want your code to print something else, you have to override the toString method of your testObject class.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic