Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4254718
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:07:19+00:00 2026-05-21T05:07:19+00:00

When running javap on a very simple HelloWorld application I have some confusion on

  • 0

When running javap on a very simple HelloWorld application I have some confusion on the output around the constant pool.

Test Code

public class TestClass {
    public static void main(String[] args) {
        System.out.println("hello world");
    }
}

Javap -c -verbose output (snipped)

// 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
}

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.

Oracle/Sun’s man page for javap leaves much to be desired.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T05:07:19+00:00Added an answer on May 21, 2026 at 5:07 am

    All your class, interface, field names and string constants go into the java constant pool.

    As per VM Spec ( http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html ):

    The constant_pool is a table of
    structures (§4.4) representing various
    string constants, class and interface
    names, field names, and other
    constants that are referred to within
    the ClassFile structure and its
    substructures. The format of each
    constant_pool table entry is indicated
    by its first “tag” byte. The
    constant_pool table is indexed from 1
    to constant_pool_count-1.

    So in terms of constant pool something like below can be viewed as:

    const #22 = String      #23;    //  hello world
    const #23 = Asciz       hello world;
    

    The value at #22 (index 22) is of type String and its value is null terminated c string (Asciz) hello world is at index 23.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple Java application which downloads a set of foreign exchanges
i've got a (probably very simple) problem with jquery. I'm running a Java Servlet
I have a very simple Java RMI Server that looks like the following: import
I'm building a very simple Java parser, to look for some specific usage models.
I get a java.lang.NoClassDefFoundError: com/hp/hpl/jena/shared/BadURIException when running a very simple servlet. The error points
I just installed Ubuntu 8.04 and Eclipse. I made a very simple Hello World
I have many small java programs running in crons in my server. I have
i am not very familar with taskdef and classname... i am having trouble running
I'm running a Java application as a Windows Service and am using another Java
I have following target in mz ant script to build my java application <target

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.