G
gk
I am always afraid of this
public class Static
{
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()
{ System.out.println(x );
y = x++ + ++x;
System.out.println(x );
}
}
ohh...horrible of ++ and ++ operator ......
+x means ...i understand...first increment and then its used in the
next statement
x+ means .....first utilized and then increment in the next statement
but still ...its pathetic to predict the output .....my headache.
public class Static
{
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()
{ System.out.println(x );
y = x++ + ++x;
System.out.println(x );
}
}
ohh...horrible of ++ and ++ operator ......
+x means ...i understand...first increment and then its used in the
next statement
x+ means .....first utilized and then increment in the next statement
but still ...its pathetic to predict the output .....my headache.