私のメソッドm1(int)
を呼び出そうとしていますが、文字列を入力として使用しようとするとエラーが発生します。foo(int)は引数(String)には適用されません
その理由は何ですか?手始めに
class TestSuper
{
public void m1(int i)
{
System.out.println("int-arg");
}
public void m1(float f)
{
System.out.println("float-arg");
}
public static void main(String[] args){
TestSuper t = new TestSuper();
t.m1(10.5f);
t.m1(10);
t.m1("Name"); // <- Where I get the error.
}
}
'String'は' float' **または** an'int'ではないためです。 –
しかし、それはcharを取ります。 – fool
'String'は' char'ではありません。 'char'は整数型です(int型に拡張することもできます)。 –