title: Concerned about nested classes
body: <p>I am working on a client server application, the server is in Delphi and I am using indy and using packed records for sending/receiving data, on the Android side I was able to find a library named javolution for converting the bytes array to class form so I can easily read the data from received packets or send data.</p>
  
  <p>A normal Packet class looks like this:</p>
  
  <pre><code>class clsCommunicatorPacket extends Struct{
      Unsigned16 signature = new Unsigned16();
      Unsigned32 version = new Unsigned32();
      Unsigned8 dataType = new Unsigned8();
      Unsigned16 bufferSize = new Unsigned16();
  
      public boolean isPacked() {
           return true; // MyStruct is packed.
       }
  
      public ByteOrder byteOrder() {
           // TopStruct and its inner structs use hardware byte order.
           return ByteOrder.nativeOrder();
      }
  }
  </code></pre>
  
  <p>Everything is working as it is supposed to so far and am having no issue, but there will be more than a 100 types of packets and I need to store them in one place so I can access/create it from any activity for sending/receiving.</p>
  
  <p>What I am thinking of doing is create a class file lets say clsAllPackets and then put all the packet classes in that class file.</p>
  
  <p>And when I need to access a specific packet class I can instantiate it like this:</p>
  
  <pre><code>clsCommunicatorPacket Pck = new clsAllPackets().new clsCommunicatorPacket();
  </code></pre>
  
  <p>So every time I need a class packet I have to instantiate the whole upper class too...</p>
  
  <p>I want to know what will be the consequences of this and how will this effect the performance of the application and what is the best alternative performance wise?</p>