How Integer Constant pool works in java

In this post, we’ll look into Integer class and what is Integer constant pool, why java has created it and it’s use.
What is Integer Class?
The Integer class wraps a value of the primitive type int in an object. An object of type Integer contains a single field whose type is int.
In addition, this class provides several methods for converting an int to a String and a String to an int, as well as other constants and methods useful when dealing with an int.
Before moving further please guess the output of the following program. If you are able to answer them all correct, then it’s means you know how Java Integer Constant pool works 🙂
public class IntegerClassExampleOne {
 public static void main(String[] javalatte) {
  Integer i = new Integer(555);
  Integer j = new Integer(555);
   System.out.println("i==j is equal");
  }else {
   System.out.println("i==j is not equal");


Click here to read further


One thought on “How Integer Constant pool works in java

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s