Code Fix

初級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

空欄を埋めてビルドを通す

広告
広告スロット(未設定)

incompatible types の原因と直し方

String / int / char / double の相互変換ルールを整理します。

このエラーの解説と類題をまとめて見る →

広告
広告スロット(未設定)