simple java program
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
class room
{
float l,b;
void getdata(float a, float c)
{
l=a;b=c;
}
}
class area
{
public static void main(String args[])
{
room obj=new room();
obj.getdata(1.2,2.3);
System.out.println(obj.b%obj.l);
}
}
|
it shows following error..
getdata(float,float) in room cannot be applied to (double,double)
why does it mean?
this is not a java forum. But what the heck:
It means that 1.2 and 2.3 are double values and not float. java does not convert that automatically
sorry ..this is my first and last java ques here..but how are 1.2 and 2.3 float and not double..!!
In C++, you can append a f to the number to force it to being a float, as in:
obj.getdata(1.2f,2.3f);
Why do you want to use floats anyway?
Topic archived. No new replies allowed.