Then the solution is to write such statements inside the appropriate methods.
See the example code below:
public class IdentifierExptectedSee the solution now:
{
int number1,number1,sum;
number1=10; // identifier expected
number2=20; // identifier expected
sum=number1+number2; // identifier expected
/*
The assignment statement must be written inside a method. Variables can also be assigned/ initialized during the declaration.
*/
public void display()
{
System.out.println("Number 1 = "+number1);
System.out.println("Number 2 = "+number2);
System.out.println("Sum = "+sum);
}
}
public class IdentifierExptectedSolved
{
int number1=10,number2=20,sum;
public void sum()
{
sum=number1+number2;
}
public void display()
{
System.out.println("Number 1 = "+number1);
System.out.println("Number 2 = "+number2);
System.out.println("Sum = "+sum);
}
}
this is fascinating. i have joined your feed and stay up for in the hunt for more of your interesting post.
ReplyDeletewww.n8fan.net
Diesel Generator on Rent
ReplyDeletehttps://palsvam.com/dg-genset-on-rent.php