package jvm;

public class ConstantPoolDemo {

    public static void main(String[] args) {
        //this will be equal since it is first time to create
        String greeting = new StringBuilder("Hello ").append("Jason").toString();
        System.out.println(greeting == greeting.intern());

        //This will not be equal since it is already created before and cached in constant pool
        String java = new StringBuilder("ja").append("va").toString();
        System.out.println(java == java.intern());
    }
}
