Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

JavaWorld Daily Brew

increment operator



Hi.

I just started learning JAVA and I am unable to understand why the following program is wrong:

import java.util.Scanner;
public class Test{
    public static void main (String args[])
{
int x, y, z;
x = 10;
y = 20;
             z=++(x+y);   
System.out.println(z);
}
}

When I try to compile the program, i get this error:

C:\Mridula_Java\Chapter_4>javac Test.java
Test.java:8: unexpected type
required: variable
found : value
z = ++(x+y);

^
1 error

Can someone help me, please?

Thank You.
- Mridula.