Tuesday, November 4, 2008



Each java statement must ends with ; (semicolon) in Java. If we don’t put ; after any statement we will see ‘;’ expected

Here is an example of this error:
public class SemicolonExpected
{
public static void main(String args[])
{
int x=10,y=10 //no ; (semicolon) is given after this statement
if(x==y)
System.out.println(x +" and "+y+" is equal");
}
}

Here no ; (semicolon) is given after the x,y declaration statement. The correct code is:

public class SemicolonExpectedSolution
{
public static void main(String args[])
{
int x=10,y=10; //; (semicolon) is given now
if(x==y)
System.out.println(x +" and "+y+" is equal");
}
}


If the above solutions do not work for you. Please comment below giving your code. I'll try to respond.

0 comments:

Post a Comment