Tuesday, November 4, 2008

Published 11/04/2008 by with 0 comment

; (semi-colon) expected

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");
}
}
    email this       edit

0 comments:

Post a Comment