Dlaczego wyjście poniższych programów jest różne? Z góry dziękuję za pomoc.
...
String a = new String("aaa");
cmp("aaa", a);
}
static void cmp(String a, String b) {
if(a == b) System.out.println("rowne");
if(a.equals(b)) System.out.println("rowne2");
}// out: rowne2
...
String a = "aaa";
cmp("aaa", a);
}
static void cmp(String a, String b) {
if(a == b) System.out.println("rowne");
if(a.equals(b)) System.out.println("rowne2");
}// out: rowne rowne2