wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes how to load the values in one object? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to load the values in one object?" Watch "how to load the values in one object?" New topic
Author

how to load the values in one object?

maggie karve
Ranch Hand

Joined: Dec 29, 2009
Posts: 186


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

Joined: Jan 10, 2002
Posts: 61310
    
  66

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Sridhar Santhanakrishnan
Ranch Hand

Joined: Mar 20, 2007
Posts: 317
You can override the toString() method in your Data class.
maggie karve
Ranch Hand

Joined: Dec 29, 2009
Posts: 186
the toString method is not working there...i tried doing it....
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

You can't override toString for arrays, but you can use the toString methods of java.util.Arrays for that.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Sridhar Santhanakrishnan
Ranch Hand

Joined: Mar 20, 2007
Posts: 317
Overriding the toString() method in Data and then calling <yourList>.toString() should list all objects.
maggie karve
Ranch Hand

Joined: Dec 29, 2009
Posts: 186
it is not happening with toStriing method too....

it is giving me an error as not recognising the method toString.....
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

Then it's not an object. Every object, even arrays, has a toString() method.
Afzal Rehman
Ranch Hand

Joined: Dec 16, 2009
Posts: 39
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.


SCJP 6.0
 
GeeCON Prague 2014
 
subject: how to load the values in one object?