-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreate.java
More file actions
60 lines (47 loc) · 1.19 KB
/
Copy pathCreate.java
File metadata and controls
60 lines (47 loc) · 1.19 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
53
54
55
56
57
58
59
60
package classesAdv;
/**
* Created by WERT on 17.01.2017.
*/
class MyStringCreate {
String myStr;
MyStringCreate(String s) {
System.out.println("MyString constructor s = " + s);
myStr = s;
}
public String toString() {
return myStr;
}
}
class Sup {
String set = "MySuperString";
Sup() {
System.out.println("Sup() перед вызовом display()");
display();
System.out.println("Sup() после вызова display()");
}
void display() {
System.out.println("Sup set = " + set);
}
}
class Sub extends Sup {
{
System.out.println("инициализационный блок 1");
}
String set = new MyStringCreate("MySubString").toString();
{
System.out.println("инициализационный блок 2");
}
void display() {
System.out.println("Sub set = " + set);
}
Sub() {
System.out.println("Sub() перед вызовом display()");
display();
System.out.println("Sub() после вызова display()");
}
}
public class Create {
public static void main(String[] args) {
new Sub();
}
}