Skip to content

Commit 3d001c6

Browse files
author
Yusuke Kanazawa
committed
サンプルコードのSystem.out.printlnをIO.printlnに変更
1 parent 78bd473 commit 3d001c6

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

documents/forJava/Javaコーディング規約.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,9 @@ head:
208208

209209
// パターンマッチングの利用しない変数
210210
switch (obj) {
211-
case String s -> System.out.println("String: " + s);
212-
case Integer _ -> System.out.println("Ignored integer");
213-
default -> System.out.println("Other type");
211+
case String s -> IO.println("String: " + s);
212+
case Integer _ -> IO.println("Ignored integer");
213+
default -> IO.println("Other type");
214214
}
215215
```
216216

@@ -1284,7 +1284,7 @@ head:
12841284
for (String s : array) {
12851285
builder.append(s);
12861286
}
1287-
System.out.println(builder.toString());
1287+
IO.println(builder.toString());
12881288
```
12891289

12901290
悪い例:
@@ -1294,7 +1294,7 @@ head:
12941294
for (String s : array) {
12951295
string += s;
12961296
}
1297-
System.out.println(string);
1297+
IO.println(string);
12981298
```
12991299

13001300
<br>
@@ -1380,7 +1380,7 @@ head:
13801380
BigDecimal a = new BigDecimal("1");
13811381
BigDecimal b = new BigDecimal("1.0");
13821382
if (a.compareTo(b) == 0) {
1383-
System.out.println("一致");
1383+
IO.println("一致");
13841384
}
13851385
```
13861386

@@ -1391,7 +1391,7 @@ head:
13911391
BigDecimal b = new BigDecimal("1.0");
13921392

13931393
if (a.equals(b)) {
1394-
System.out.println("精度が違うためこの分岐には入らない");
1394+
IO.println("精度が違うためこの分岐には入らない");
13951395
}
13961396
```
13971397

@@ -1503,7 +1503,7 @@ head:
15031503
// ...処理
15041504
Instant end = Instant.now();
15051505
Duration duration = Duration.between(start, end);
1506-
System.out.println("処理時間: " + duration.toMillis() + "ミリ秒");
1506+
IO.println("処理時間: " + duration.toMillis() + "ミリ秒");
15071507
```
15081508

15091509
- `ZonedDateTime`と`OffsetDateTime`を使い分ける
@@ -2272,7 +2272,7 @@ head:
22722272
```java
22732273
static void execute(Object obj) {
22742274
if (obj instanceof Point(int x, int y)) {
2275-
System.out.println(x + y);
2275+
IO.println(x + y);
22762276
}
22772277
}
22782278
```
@@ -2283,7 +2283,7 @@ head:
22832283
if (obj instanceof Point p) {
22842284
int x = p.x();
22852285
int y = p.y();
2286-
System.out.println(x+y);
2286+
IO.println(x+y);
22872287
}
22882288
```
22892289

@@ -2427,7 +2427,7 @@ head:
24272427
String message = \"""
24282428
テキストブロックです。
24292429
\""";
2430-
System.out.println(message);
2430+
IO.println(message);
24312431
""";
24322432
```
24332433
@@ -2438,14 +2438,14 @@ head:
24382438
String message = \"\"\"
24392439
テキストブロックです。
24402440
\"\"\";
2441-
System.out.println(message);
2441+
IO.println(message);
24422442
""";
24432443
24442444
String javaCode = """
24452445
String message = ""\"
24462446
テキストブロックです。
24472447
""\";
2448-
System.out.println(message);
2448+
IO.println(message);
24492449
""";
24502450
```
24512451

0 commit comments

Comments
 (0)