title: Best practice for getting datatype size(sizeof) in Java
body: <p>I want store a list of doubles and ints to a ByteBuffer, which asks for a size to allocate. I'd like to write something like C's syntax</p>
  
  <pre><code>int size=numDouble*sizeof(double)+numInt*sizeof(int);
  </code></pre>
  
  <p>But there is no <code>sizeof</code> in Java. What is the best practice to calculate the size in byte? Should I hardcode it?</p>