title: What structure of data use to communicate via tcp/ip in java?
body: <p>Let's assume I want to send many messages between 2 programs made in java that use TCP sockets.</p>
  
  <p>I think the most convienient way is to send objects like:</p>
  
  <pre><code>PrintStream ps = new PrintStream(s.getOutputStream());
  
  ObjectOutputStream oos = new ObjectOutputStream(ps);
  
    some_kind_of_object_here;
  
    oos.writeObject(some_kind_of_object_here);
  
   ps.print(oos);
  </code></pre>
  
  <p>I want to send, strings, numbers, HashMaps, boolean values
  How can I do this using fx 1 object that can store all that properties?
  I though about ArrayList that is serializable and we can put there everything but is not elegant way.
  I want to send different types of data because user can choose from a variety of options that server can do for it.
  Any advices?</p>