title: Java sockets - Custom Objects Sending
body: <p>I have created working sockets, and when I try to send text or numbers, its ok, but when im trying to send my custom class object, i got NullPointerException...
  Here is some code:</p>
  
  <pre><code>public boolean SendLi(List&lt;Entity&gt; list)
  {
      try {
           out.writeObject(list);
      } catch (IOException e) {
          e.printStackTrace();
          System.err.println("Send: Error on OutputStream.write(byte[])");
      }
      return true;
  }
  
  public List&lt;Entity&gt; RecvLi()
  {
      List&lt;Entity&gt; data;
      data = new ArrayList&lt;Entity&gt;();
        try{
            data = (List&lt;Entity&gt;) in.readObject();
          } catch (IOException e) {
            System.err.println("Send: Error on OutputStream.read(byte[]) - IOException");
            return null;
          } catch (ClassNotFoundException e) {
            System.err.println("Send: Error on OutputStream.read(byte[]) - ClassNotFound");
              e.printStackTrace();
          }
      return data;
  }
  </code></pre>
  
  <p>Actually, that code I made for Lists, but I want to have some simmilar functions to send other objects. 
  Thanks for any replies!</p>