Query in below java code

String a= "/u0041";
String h=new String("A");
System.out.println(a==h);
System.out.println(a.hashCode()==h.hashCode());


Please explain why the second print statement is giving false when in the string pool we have the same string literal "A".

Replies

You are reading an archived discussion.

Related Posts

Quote: An autonomous Audi RS 7 concept car has completed a lap on the Grand Prix track in Hockenheim in a little over two minutes. Endquote https://www.theengineer.co.uk/news/a...ial/1019396.article?cmpid=tenews_619096#video
Somebody experienced in Matlab please contact me. I need to run c++ program in matlab.
Quote: The Internet of Things has been riding the crest of a wave of attention in the technology and financial media in recent years. “We think the Internet of Things...
Quote: Eric Betzig, who just won the Nobel Prize in Chemistry for super-resolved fluorescence microscopy, and colleagues at the Howard Hughes Medical Institute, have developed a new 3D microscopy technique...
The Ebola is going online and has began affecting computers. The bad guys on the Internet have coded a malware that arrives through email and affects vulnerable computers and do...