public class Main {
public static void main(String[] args) {
String s = "hello";
final String lo = "lo";
String[] arr1 = {
"hello",
"hel" + "lo",
"hel" + lo,
new String("hello").intern()
};
String[] arr2 = {
new String("hello"),
"hel".concat("lo"),
" hello ".trim(),
new StringBuilder("hello").toString()
};
System.out.println("arr1:");
for (int i = 0; i < arr1.length; i++) {
System.out.print((s == arr1[i]) + " ");
}
System.out.println("\narr2:");
for (int i = 0; i < arr2.length; i++) {
System.out.print((s == arr2[i]) + " ");
}
}
}