title: how to initialize a static array of objects in java
body: <p>Basically I want to create a data structure of values already known at compile time. In C I'd do it like this:</p>
  
  <pre><code>struct linetype { int id; char *descr; };
  
  static struct linetype mylist[] = {
      { 1, "first" },
      { 2, "second" }
  };
  </code></pre>
  
  <p>The only soultion I have found in Java involves creating the array at runtime:</p>
  
  <pre><code>public class Outer {
  
      public class LineType {
          int id;
          String descr;
  
          private LineType( int a, String b) {
            this.id = a;
            this.descr = b;
          }
      }
  
      LineType[] myList = { 
          new LineType( 1, "first" ),
          new LineType( 2, "second" ),
      };
  </code></pre>
  
  <p>This appears cumbersome and ineffective (when the structures get long and complex). Is there another way? </p>
  
  <p>(NB: please disregard any syntax errors as this is only sample code created for this question. Also, I am aware a String is somethign else than a character pointer pointing into the data segment. However, the argument works with primitive data types as well).</p>