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

Serializable ArrayList

 
david foley
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am trying to Read my Serialize data back into the Program.
but when i click on load the console is giving me back this

Person@3b7418ba
Person@430379d4

Is their Any Way of getting it into a String.
 
Greg Charles
Sheriff
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, although it's not related to serialization. You just need to override the toString() method in your Person class to build up a String representation in any format you want.
 
david foley
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,

I'll will give this go,

Should a create another method

Public String tostring()
{
Return Id + "" + firstname + "" + last name;
}
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David

To ensure you override the toString method properly, use this:
 
Tony Docherty
Bartender
Posts: 2965
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James Boswell wrote:To ensure you override the equals method properly, use this:

I think you mean "To ensure you override the toString method properly..."
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tony, I've posted something similar on another thread and got my method names mixed up!
 
david foley
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks Lads that worked well.


You couldn't point me to a direction,

on How you can get the File to Read into Text Fields. i have a number of Text Fields
for First Name etc..

and Use a Next Button to display the Next Serialize data on File ("For the Next Button i would have to use maybe a Loop")
since i am using ArrayList i wouldn't have to check if its at the end of file as ArrayList should do this automatically
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic