title: Understanding javap's output for the Constant Pool
body: <p>When running javap on a very simple HelloWorld application I have some confusion on the output around the constant pool.</p>
  
  <p><strong>Test Code</strong></p>
  
  <pre><code>public class TestClass {
      public static void main(String[] args) {
          System.out.println("hello world");
      }
  }
  </code></pre>
  
  <p><strong>Javap -c -verbose output (snipped)</strong></p>
  
  <pre><code>// Header + consts 1..22 snipped
  const #22 = String      #23;    //  hello world
  const #23 = Asciz       hello world;
  
  public static void main(java.lang.String[]);
    Signature: ([Ljava/lang/String;)V
    Code:
     Stack=2, Locals=1, Args_size=1
     0:   getstatic       #16; //Field java/lang/System.out:Ljava/io/PrintStream;
     3:   ldc     #22; //String hello world
     5:   invokevirtual   #24; //Method java/io/PrintStream.println:(Ljava/lang/String;)V
     8:   return
    // Debug info snipped
  }
  </code></pre>
  
  <p>Ok, so on line 3 we see a pushing of the "hello world" constant onto the stack via #22, but const #23 seems to hold the actual value. I guess I am a little confused with what the #(number) means when it appears on the right-hand-side of the printout. </p>
  
  <p><a href="http://download.oracle.com/javase/1.5.0/docs/tooldocs/windows/javap.html">Oracle/Sun's man page for javap</a> leaves much to be desired. </p>