-7
class Smartphone
{
private float screensize;
private float androidversion;
private int ram;
private int memory;
private int processor;
private String brand;
//I also created String brand variable...at the rite position
public void setData(String brand,int screensize,int ram,int memory,int processor,float androidversion)
{
this.screensize=screensize;
this.androidversion=androidversion;
this.ram=ram;
this.memory=memory;
this.processor=processor;
this.brand=brand;
}
public void dispData()
{
System.out.println("the brand of the mobile is "+brand+"Smartphones");
System.out.println("the screensize of the mobile is "+screensize+"inches");
System.out.println("the ram of the mobile is "+ram);
System.out.println("the memory of the mobile is "+memory+"GB");
System.out.println("the processor of the mobile is "+processor+"Ghz");
System.out.println("the androidversion of the mobile is "+androidversion);
}
}
class App
{
public static void main(String args[])
{
Smartphone xiaomi=new Smartphone();
//Error is causing here...the xiaomi string is not passing..
xiaomi.setData("Xiaomi",5.5,3,32,2.6,8.0);
}
}
看看下一個參數。你試圖爲int參數傳遞一個double。 –
是你的Locale中的一個整數? –
是的,它是整數....我改變它漂浮...謝謝btw –