回答編集履歴
1
追記
test
CHANGED
@@ -1 +1,75 @@
|
|
1
1
|
`methodName(args)`は、`this.methodName(args)`と同じ意味です。
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
実験
|
6
|
+
|
7
|
+
---
|
8
|
+
|
9
|
+
```Java
|
10
|
+
|
11
|
+
class MyClass {
|
12
|
+
|
13
|
+
void print(String str) {
|
14
|
+
|
15
|
+
System.out.println("called: " + str);
|
16
|
+
|
17
|
+
}
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
void func() {
|
22
|
+
|
23
|
+
this.print("this.print()");
|
24
|
+
|
25
|
+
print("print()");
|
26
|
+
|
27
|
+
}
|
28
|
+
|
29
|
+
}
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
class Main {
|
34
|
+
|
35
|
+
Main() {
|
36
|
+
|
37
|
+
// print(); もちろんここからは呼べない
|
38
|
+
|
39
|
+
}
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
public static void main(String[] args) {
|
44
|
+
|
45
|
+
MyClass mc = new MyClass();
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
mc.print("インスタンス名.print()");
|
50
|
+
|
51
|
+
mc.func();
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
new Main();
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
}
|
60
|
+
|
61
|
+
```
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
**実行結果** [Wandbox](https://wandbox.org/permlink/kwFbF8GbrXmBFENJ)
|
66
|
+
|
67
|
+
```
|
68
|
+
|
69
|
+
called: インスタンス名.print()
|
70
|
+
|
71
|
+
called: this.print()
|
72
|
+
|
73
|
+
called: print()
|
74
|
+
|
75
|
+
```
|