How is the output of this simple java code 6 and not 4? : How is the output of this simple java code 6 and not 4? Also since int x = 10 and int y = 15, how come they are able to declare int x and int y again to be 5 and x-2? I thought you can only declare the value of an int once? thanks, sorry I'm new to java.

here's the code:

    public class shortq
    {
	 public static void main (String args[])
	 {
	 int x = 10 , y =15;
	 x = 5;
	 y = x-2;
	 System.out.println(x+1);
	    }
   } 