回答編集履歴
2
作文の修正。「です」が続きすぎなので...
test
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
System.outはSystemクラスのstaticフィールドで、型はPrintStreamです。
|
2
2
|
|
3
|
-
printやprintlnは、System
|
3
|
+
printやprintlnは、SystemではなくPrintStreamのメソッドとして定義されています。
|
4
4
|
|
5
5
|
[クラスSystem - out](https://docs.oracle.com/javase/jp/8/docs/api/java/lang/System.html#out)
|
6
6
|
|
1
追記
test
CHANGED
@@ -3,3 +3,37 @@
|
|
3
3
|
printやprintlnは、SystemのメソッドではなくPrintStreamのメソッドです。
|
4
4
|
|
5
5
|
[クラスSystem - out](https://docs.oracle.com/javase/jp/8/docs/api/java/lang/System.html#out)
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
要は、こう書いても良いということです。
|
10
|
+
|
11
|
+
```Java
|
12
|
+
|
13
|
+
import java.io.PrintStream;
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
class Main {
|
18
|
+
|
19
|
+
public static void main(String[] args) {
|
20
|
+
|
21
|
+
PrintStream ps = System.out;
|
22
|
+
|
23
|
+
ps.println("hogehoge");
|
24
|
+
|
25
|
+
}
|
26
|
+
|
27
|
+
}
|
28
|
+
|
29
|
+
```
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
**実行結果** [Wandbox](https://wandbox.org/permlink/dkht0msZwnx7QhiD)
|
34
|
+
|
35
|
+
```
|
36
|
+
|
37
|
+
hogehoge
|
38
|
+
|
39
|
+
```
|