title: Java: Generic serialize method
body: <p>It is possible to make a generic serialize method? In which I can pass any object and serialize it acording to it's class? Something like this:</p>
  
  <pre><code>public void serializeObject(T Object) {
  
      try (ObjectOutputStream clientOutputStream = new ObjectOutputStream(socketConnection.getOutputStream());) {
  
          clientOutputStream.writeObject(Object);
  
          System.out.println(user.getUsername());
  
          //clientOutputStream.close();
  
      } catch (Exception e) {
          System.out.println(e);
      }
  }
  </code></pre>