回答編集履歴
3
追記
test
CHANGED
@@ -64,14 +64,6 @@
|
|
64
64
|
|
65
65
|
```
|
66
66
|
|
67
|
-
|
68
|
-
|
69
|
-
そのためコンパイルエラーになります。
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
67
|
原文はこれです。
|
76
68
|
|
77
69
|
5.3. Invocation Contexts
|
@@ -80,6 +72,18 @@
|
|
80
72
|
|
81
73
|
|
82
74
|
|
75
|
+
そのためコンパイルエラー(リンク先の英文太文字部分は回答者強調)が発生します。
|
76
|
+
|
77
|
+
5.3. Invocation Contexts
|
78
|
+
|
79
|
+
> If the type of the expression cannot be converted to the type of the parameter by a conversion permitted in a loose invocation context, **then a compile-time error occurs.**
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
|
83
87
|
◇参考
|
84
88
|
|
85
89
|
[Java言語規定 5. 変換及び昇格](http://www.y-adagio.com/public/standards/tr_javalang/5.doc.htm)
|
2
追記
test
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
コンパイルエラーを無くすだけなら、関数の引数をint型で定義することをすごーくお勧めしますが。
|
2
2
|
|
3
|
-
`car.turn((byte)15, 'L');`
|
3
|
+
メソッドの引数の型を`byte`型から変更できない場合は、明示的にbyte型にキャストをおこなってください。`car.turn((byte)15, 'L');`。
|
4
4
|
|
5
5
|
|
6
6
|
|
1
追記
test
CHANGED
@@ -50,17 +50,17 @@
|
|
50
50
|
|
51
51
|
```Java
|
52
52
|
|
53
|
-
|
53
|
+
public void turn(byte speed, char direction) { // byte で定義
|
54
54
|
|
55
|
-
|
55
|
+
System.out.println("The car is turning " + direction + " by " + speed + " km/h.");
|
56
56
|
|
57
|
-
|
57
|
+
}
|
58
58
|
|
59
|
-
|
59
|
+
public void turn(short speed, char direction) { // shortで定義
|
60
60
|
|
61
|
-
|
61
|
+
System.out.println("The car is turning " + direction + " by " + speed + " km/h.");
|
62
62
|
|
63
|
-
|
63
|
+
}
|
64
64
|
|
65
65
|
```
|
66
66
|
|
@@ -77,3 +77,9 @@
|
|
77
77
|
5.3. Invocation Contexts
|
78
78
|
|
79
79
|
> Neither strict nor loose invocation contexts include the implicit narrowing of integer constant expressions which is allowed in assignment contexts. The designers of the Java programming language felt that including these implicit narrowing conversions would add additional complexity to the rules of overload resolution (§15.12.2).
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
◇参考
|
84
|
+
|
85
|
+
[Java言語規定 5. 変換及び昇格](http://www.y-adagio.com/public/standards/tr_javalang/5.doc.htm)
|