wood burning stoves*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Is String[ ] Serializabel? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Is String[ ] Serializabel?" Watch "Is String[ ] Serializabel?" New topic
Author

Is String[ ] Serializabel?

Peter Yunguang Qiu
Ranch Hand

Joined: Nov 22, 2003
Posts: 99
String[] str = new String[7];
str= data.readRecord(recNo);
Is str serializiabel? Can it be transmitted by rmi or socket or ObjectStream?


Peter
Vinod Chandana
Ranch Hand

Joined: Aug 26, 2003
Posts: 59
To the best of my knowledge, string is serializable. I was able to send string using rmi as well as sockets
Regards,
Vinod.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
An array is serializable as long as it's an array of a Serializable reference type, or an array of privitives. So String[] is serializable because String is serializable.


"I'm not back." - Bill Harding, Twister
Peter Yunguang Qiu
Ranch Hand

Joined: Nov 22, 2003
Posts: 99
thanks Jim and Vinod
Peter Yunguang Qiu
Ranch Hand

Joined: Nov 22, 2003
Posts: 99
Hi Jim:
Thanks for your acurate explaination.
An array is serializable as long as it's an array of a Serializable reference type, or an array of privitives. So String[] is serializable because String is serializable.

String array is serializable and we can transmit it throug net-work or to files. So, do you think we also need to create a class Record

what approach is better, using String[] or class Record to transmit data?
Peter Yunguang Qiu
Ranch Hand

Joined: Nov 22, 2003
Posts: 99
Anyone has a good idea?
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
String array is serializable and we can transmit it throug net-work or to files. So, do you think we also need to create a class Record
You don't need to, but you're allowed to if you want.
what approach is better, using String[] or class Record to transmit data?
I think that depends on whether you use a fat client or thin client design. Or as they're commonly but misleadingly called here, 2-tier or 3-tier. Read this thread until you get bored, make a decision, and then don't worry about it. If you use the "2 tier" model, you wouldn't have a Record class in your networking code; you'd just use String[]. If you use "3-tier" you have the option of using a Record class. In this case I think you could go either way - I don't think it matters much whether you use a new class or not. Perhaps others have strong opinions on this though.
Peter Yunguang Qiu
Ranch Hand

Joined: Nov 22, 2003
Posts: 99
Hi, Jim:
thanks for your help.
I think use String[] is staitforward. Using an objects of class Record need more unneccesary work, but does that means good OO Design?
I am not clear with 2-tier and 3-tier, could you explain?
Peter
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11432
    
  85

Hi Peter
I am not clear with 2-tier and 3-tier, could you explain?

See the link Jim pointed you at for a long discussion on it.
Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is String[ ] Serializabel?