From 4531049ff260118822f8b28f7c88e8f09dd90cf4 Mon Sep 17 00:00:00 2001 From: Oleksii Aleshchenko Date: Thu, 6 Apr 2023 16:07:04 +0300 Subject: [PATCH] add lab3 --- src/Lab3.java | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/Lab3.java diff --git a/src/Lab3.java b/src/Lab3.java new file mode 100644 index 0000000..1bf2cf0 --- /dev/null +++ b/src/Lab3.java @@ -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!"); + } +}