さまざまなメソッドを呼び出していますが、パラメーターの整数値はすべてデフォルトで int になり、1 や 0 などの値であっても、型キャスト以外にこれを解決するためにすべきことはありますか? これがコードの例です
public class Launch {
public static void main(String[] args) {
CoordinateHandler handler = new Handler();
short x = 3901;
short y = 5921;
byte h = 2;
handler.toCoordinates(x, y, h, "modern");
}
}
public class CoordinateHandler extends CoordinateMain {
public void toCoordinates(short absX, short absY, byte height, String type) {
if (type.equals("modern")) {
super.toCoordinates(absX, absY, height);
} else {
coordinateUpdateEvent(absX, absY, height, type);
}
}
}
short x、short y、および byte h の行で精度が失われる可能性があるというコンパイル エラーが発生し、toCoordinates(int, int, int, String) can't be applied to toCoordinates というコンパイル エラーも発生します。 (ショート、ショート、バイト、文字列)