class T {
public static void main(
String args[]) {
String a = "1";
byte b = 2;
short c = 3;
char d = 4;
int e = 5;
float f = 2;
a += b *= c += d *= e += f;
System.out.print(a);
}
}
The answer is 162 .. cant' figure out why its right associative and how can one rewrite it..
And wont the float=2.0 give a compile time error coz it should be float = 2.0f.. but ignoring that still can someone help!
secondly..
class C {
static int m(int i) {
System.out.print(i + ", ");
return i;
}
public static void main(String s[]) {
int i = 1;
m(m(++i) - m(i++) + ~m(-i) * -m(~i));
}
}
The answer is 2, 2, -3, -4, 8... i can go upto -3 but how do we get -4. coz for -m(~i) we send the value ~3 which is 0.
Where am i going wrong..??