Showing posts with label Data Type. Show all posts
Showing posts with label Data Type. Show all posts

Friday, October 30, 2009

Published 10/30/2009 by with 1 comment

incompatible types

1. Sometimes we may get the following error message in an 'if' (selection) structure. incompatible typesfound : intrequired: boolean This is because, we have not specified a boolean expression as the condition of the 'if'; instead we might have written such an expression which is may be int, float, String or other types but not boolean. See the code below: int a=10,b=10; if(a=b){ System.out.println("a...
Read More
    email this       edit

Sunday, November 9, 2008

Published 11/09/2008 by with 2 comments

possible loss of precision

You may see the error message 'possible loss of precision' for any of the following reasons: 1) You are trying to assign a fractional number into a float variable(why not?). Actually Java compiler considers the fractional number as double by default. You need to explicitly specify the fractional number as float by giving the character 'f' or 'F' after the the number, like float number = 65.37F; 2)...
Read More
    email this       edit
Published 11/09/2008 by with 1 comment

integer number too large

We know that the maximum value of an int is 2147483647. If we write any whole number more than 2147483647 in our Java program, we may get this error message 'integer number too large' but may be you are trying to store this large number in a long type variable, then what to do? The solution is to put the letter 'l' or 'L' after the number. This happens, because the compiler considers the whole number...
Read More
    email this       edit