回答編集履歴
3
アスキーコードの勘違い
test
CHANGED
@@ -22,13 +22,13 @@
|
|
22
22
|
|
23
23
|
public class ClassB {
|
24
24
|
|
25
|
-
public static int a =
|
25
|
+
public static int a = 97;
|
26
26
|
|
27
|
-
static int b =
|
27
|
+
static int b = 98;
|
28
28
|
|
29
|
-
public int c =
|
29
|
+
public int c = 99;
|
30
30
|
|
31
|
-
int d =
|
31
|
+
int d = 100;
|
32
32
|
|
33
33
|
|
34
34
|
|
@@ -112,7 +112,7 @@
|
|
112
112
|
|
113
113
|
|
114
114
|
|
115
|
-
[Wandbox](https://wandbox.org/permlink/g
|
115
|
+
[Wandbox](https://wandbox.org/permlink/WgAGsUP7meN8Hsbc)
|
116
116
|
|
117
117
|
|
118
118
|
|
2
追記
test
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
- **public** クラスやメソッドへのアクセスが制限されないことを意味します。
|
5
|
+
- **public** クラスやメソッドへのアクセス範囲が制限されないことを意味します。
|
6
6
|
|
7
7
|
- **static** クラスをインスタンス化しないでもアクセスできることを意味します。
|
8
8
|
|
1
修正
test
CHANGED
@@ -29,6 +29,40 @@
|
|
29
29
|
public int c = 44;
|
30
30
|
|
31
31
|
int d = 45;
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
public ClassB() {
|
36
|
+
|
37
|
+
}
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
ClassB(int dummy) {
|
42
|
+
|
43
|
+
System.out.println(ClassB.a);
|
44
|
+
|
45
|
+
System.out.println(this.a);
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
System.out.println(ClassB.b);
|
50
|
+
|
51
|
+
System.out.println(this.b);
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
//System.out.println(ClassB.c);
|
56
|
+
|
57
|
+
System.out.println(this.c);
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
//System.out.println(ClassB.d);
|
62
|
+
|
63
|
+
System.out.println(this.d);
|
64
|
+
|
65
|
+
}
|
32
66
|
|
33
67
|
}
|
34
68
|
|
@@ -78,8 +112,8 @@
|
|
78
112
|
|
79
113
|
|
80
114
|
|
81
|
-
[Wandbox](https://wandbox.org/permlink/
|
115
|
+
[Wandbox](https://wandbox.org/permlink/ggox65IDTbiVQJ1a)
|
82
116
|
|
83
117
|
|
84
118
|
|
85
|
-
コメントを一つでも外すとエラーが出ます
|
119
|
+
コメントを一つでも外すとエラーが出ます。その理由について考えてみると良いでしょう。
|