simple java program

vgoel38 (113)
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?
coder777 (2378)
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
vgoel38 (113)
sorry ..this is my first and last java ques here..but how are 1.2 and 2.3 float and not double..!!
TheIdeasMan (1564)
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?
Registered users can post here. Sign in or register to post.