public class Comparison { public static void main(String[] args) { String s = \"prova\"; String s2 = \"prova\"; System.
The JVM may optimize the String usage so that there is only one instance of the "equal" String in memory. In this case also the == operator will return true. But don't count on it, though.