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

  • SEARCH
  • Home
  • 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 have a very simple crawler. I want to make my current code run
i've got a (probably very simple) problem with jquery. I'm running a Java Servlet
I have a terrible problem that hopefully has a very simple answer. I am
I get a java.lang.NoClassDefFoundError: com/hp/hpl/jena/shared/BadURIException when running a very simple servlet. The error points
For a very simple application, package mypackage; import javax.swing.*; public class Main { public
I have a bunch of very simple functions. Each function has one input and
I am a JPA newbie. I have what I believe is a very simple
I have a very simple Java JTable question. I am creating this class to
I have a java threads related question. To take a very simple example, lets

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.