Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to load the values in one object?

 
maggie karve
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


when i print for size of table ..i get correct values i.e.4..
but when i want the actual values from the table and i ask System.out.println(b1);

it prints some values like [myServlets.Data@451c0d60, myServlets.Data@34b23d12, myServlets.Data@21c783c5, myServlets.Data@319c0bd6]

i want actual values..
this is silly and it will require a simple java statement,but i don know how to access that..


there is no problem with sql ,no problem with post or get method definition....
Thanks.....
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64980
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is simple Java -- that's what's returned from the default toString() of the base Object class. If you want to extract and emit the value for the List, you'll need to iterate over the list.

I have moved this to a more appropriate forum.
 
Sridhar Santhanakrishnan
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can override the toString() method in your Data class.
 
maggie karve
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the toString method is not working there...i tried doing it....
 
Rob Spoor
Sheriff
Pie
Posts: 20552
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't override toString for arrays, but you can use the toString methods of java.util.Arrays for that.
 
Sridhar Santhanakrishnan
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Overriding the toString() method in Data and then calling <yourList>.toString() should list all objects.
 
maggie karve
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it is not happening with toStriing method too....

it is giving me an error as not recognising the method toString.....
 
Rob Spoor
Sheriff
Pie
Posts: 20552
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then it's not an object. Every object, even arrays, has a toString() method.
 
Afzal Rehman
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what ever is your data class you should have to override the toString method and gives the appropriate values.
Whatever you expect. toString method will give understandable representation of object.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic