The difference depends on the presence of the String in the heap / pool. The == comparison compares the String with the ones in the pool while .equals does a character by character comparison with another String.
String x = "ravi"; creates a string in the string pool
String x = new String("ravi"); creates a string in the pool and heap
1) We know that the equality sign '==' means 'equal in reference' but that
for the String object the equality sign will return TRUE if they are referring
to the same string in the heap (i.e. not instantiating a new String object with the keyword "new")
2) Assuming that we run the application passing an argument (below, using "arg1" as a string argument)
why the behaviour is different using the argv array compared to another array when we pass the String
value to a String variable?
... what is different about the argv array?
If you run the following code with "arg1" as an argument, maybe is more clear what i'm trying to say...