• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Is String[ ] Serializabel?

 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
String[] str = new String[7];
str= data.readRecord(recNo);
Is str serializiabel? Can it be transmitted by rmi or socket or ObjectStream?
 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To the best of my knowledge, string is serializable. I was able to send string using rmi as well as sockets
Regards,
Vinod.
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Peter Yunguang Qiu
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Jim and Vinod
 
Peter Yunguang Qiu
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anyone has a good idea?
 
Jim Yingst
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
reply
    Bookmark Topic Watch Topic
  • New Topic