初級 › incompatible types の原因と直し方 › パターン5
incompatible types の原因と直し方
型が合わない代入で出ます。
1 public class Main { 2 static void printDouble(int n) { 3 System.out.println(n * 2); 4 } 5 public static void main(String[] args) { 6 printDouble(___); ^ 7 } 8 }
Main.java:6: error: incompatible types: String cannot be converted to int
空欄を埋めてビルドを通す
引数にもその型と一致する値が必要です。数値の見た目でも文字列は数値として渡せません。
次の問題