質問編集履歴
1
文法の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -20,3 +20,28 @@
|
|
20
20
|
}
|
21
21
|
}
|
22
22
|
```
|
23
|
+
|
24
|
+
【追記】
|
25
|
+
```Sample.java
|
26
|
+
package ex3;
|
27
|
+
|
28
|
+
public class Sample {
|
29
|
+
static protected void methodA() { // static修飾
|
30
|
+
System.out.println("Super#method() called.");
|
31
|
+
}
|
32
|
+
}
|
33
|
+
```
|
34
|
+
```SampleImpl.java
|
35
|
+
package ex4;
|
36
|
+
import ex3.Sample;
|
37
|
+
|
38
|
+
public class SampleImpl extends Sample {
|
39
|
+
public static void main(String[] args) {
|
40
|
+
Sample s = new Sample(); // スーパークラスのインスタンス生成
|
41
|
+
s.methodA(); // インスタンスメソッド呼出
|
42
|
+
}
|
43
|
+
}
|
44
|
+
```
|
45
|
+
参考サイトも参考に修正しました。
|
46
|
+
コンパイル&実行結果「Super#method() called.」と正常に出力されました。
|
47
|
+
|