This commit is contained in:
Oleksii Aleshchenko 2023-04-06 16:07:04 +03:00
parent 07b17ca3cc
commit 4531049ff2
1 changed files with 26 additions and 0 deletions

26
src/Lab3.java Normal file
View File

@ -0,0 +1,26 @@
public class Lab3 {
public static void main(String[] args) {
String s = "ASD";
String s2 = s;
System.out.println("s2 = " + s2);
System.out.println(s == s2); // true?
System.out.println(s.equals(s2)); // true?
s += "B";
System.out.println(s);
System.out.println("s2 = " + s2);
System.out.println(s == s2); // false?
System.out.println(s.equals(s2)); // false?
String s3 = new String("ASD");
System.out.println(s3 == s2); // true? (false)
System.out.println(s3.equals(s2)); // false? (true)
// String Pool
String s4 = "ASD";
System.out.println(s4 == s2); // true?
System.out.println(s4.equals(s2)); // (true)
System.out.println("Done!");
}
}