Showing posts with label Variable. Show all posts
Showing posts with label Variable. 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, May 17, 2009

Published 5/17/2009 by with 2 comments

identifier expected

This error message is shown when the statements are not written in proper place. Most often, mistakenly, we may write the processing task (for example assigning value to a variable; writing a loop etc.) outside of any method. In this situation we may see this type of error message. Then the solution is to write such statements inside the appropriate methods. See the example code below: public class...
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

Tuesday, November 4, 2008

Published 11/04/2008 by with 0 comment

variable … might not have been initialized

We see “variable might not have been initialized” when we try to use the value of a variable before assigning any value to that variable. Each local variable must be assigned a value before further using it. Here is an example of this error : public class VariableMightNotHaveBeenInitialized { public static void main(String args[]) { int a,b,c; a=10; c=a+b; System.out.println("The sum is "+c); } } Here...
Read More
    email this       edit
Published 11/04/2008 by with 0 comment

cannot find symbol / cannot resolve symbol

“cannot find symbol” or “cannot resolve symbol” is the most common error message which the programmers get from the compiler. However this error message may mean that the variable/method/class/object used are not declared/defined properly. In most cases, this happens because: · The variable/object is not declared or the spelling of variable/object declaration & later use of that variable/object...
Read More
    email this       edit