can anyone please explain me why the output is 3.And x-- should be 0.since it changes to 1 only in next place of x right ,as it is a post increment..Am i right ...Please explain this.
public class sample12 {
static{
int x=5;
}
static int x,y;
public static void main(
String[] args) {
x--;
myMethod();
System.out.println(x+y + ++x);
}
public static void myMethod(){
y=x++ + ++x;
}
}