Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
String object comparision
//'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_111 import java.util.*; import java.lang.*; class Rextester { public static void main(String args[]) { String str = "abc"; String str2= "abc"; String str3= new String("abc"); System.out.println("str, str2, st3"+str+str2+str3); System.out.println("(str==str2)"+(str==str2)); System.out.println("str.equals(str2)"+str.equals(str2)); System.out.println("(str==str3)"+(str==str3)); System.out.println("str.equals(str3)"+str.equals(str3)); System.out.println("str.intern() == str3.intern() = "+(str.intern() == str3.intern())); System.out.println("str.intern() == str2.intern() = "+(str.intern() == str2.intern())); Map obj = new HashMap(); obj.put("abc", 1); obj.put( 1, "abc"); System.out.println(""+obj); System.out.println(""+(obj.get(1)==str)); System.out.println(""+(obj.get(1)==str3)); } }
run
|
edit
|
history
|
help
0
luas
classwork
Vikas
palin
2_Arpan Subba_Lincoln.java
Weird float operation!
Lincoln1_Surafel
PE #9
classwork
Has A