Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Is String[ ] Serializabel?

 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • Quote
  • Report post to moderator
thanks Jim and Vinod
 
Peter Yunguang Qiu
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Anyone has a good idea?
 
Jim Yingst
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
  • 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
  • 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: 12199
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
  • 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
 
If you send is by car it's a shipment, but if by ship it's cargo. This tiny ad told me:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic