-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClasses013.java
More file actions
52 lines (44 loc) · 1.81 KB
/
Copy pathClasses013.java
File metadata and controls
52 lines (44 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package classesIntro;
/**
* Created by WERT on 13.01.2017.
*/
public class Classes013 {
public static void main(String[] args) {
System.out.println("------- str1 & str2 --------");
Str str1 = new Str("Str1");
str1.printStrHash();
String str2 = "Str1";
System.out.println("хэш объекта str2 = " + System.identityHashCode(str2) + " строка = " + str2);
System.out.println("\n------- str3 & str4 --------");
Str str3 = new Str(new String("Str1"));
str3.printStrHash();
String str4 = str3.getStr();
System.out.println("хэш объекта str4 = " + System.identityHashCode(str4) + " строка = " + str4);
System.out.println("\n------- str4 --------");
str4 = str4.intern();
System.out.println("хэш объекта str4 = " + System.identityHashCode(str4) + " строка = " + str4);
System.out.println("\n------- Arrays --------");
Dim dim1 = new Dim("один", "два", "три");
System.out.print("Массив в классе Dim: ");
for (String str : dim1.getStrArray()) {
System.out.print(" " + str);
}
System.out.println();
String[] strArray = dim1.getStrArray();
for (int i = 0; i < strArray.length; ++i) {
strArray[i] = String.valueOf(i + 1);
}
System.out.print("Массив в классе Dim: ");
for (String str : dim1.getStrArray()) {
System.out.print(" " + str);
}
dim1.setIndex(0, "one");
dim1.setIndex(1, "two");
dim1.setIndex(2, "three");
System.out.println();
System.out.print("Массив в классе strArray: ");
for (String str : strArray) {
System.out.print(" " + str);
}
}
}