When i declare the below statement it shows error,
float f=12.1; //Type mismatch: cannot convert from double to float
You're missing the f at the end:
If you just put "12.1", that would be a double (64 bits). And you're trying to fit that "double" (64 bits) into a float (32 bits)=won't work. If you just need a float (32 bits), you have to tell java you want that. Thus the f at the end.
A floating-point literal is of type float if it ends with the letter F or f; otherwise its type is double and it can optionally end with the letter D or d.