public class MainClass
{
public static void main(String[] args)
{
int i = 13 - - 14 + + 15;
// evaluate this as Right to Left associativity
// so (13 - (-14)) + + 15 = 27 + +15 = 42 --> correct
System.out.println(i);
}
}
Since + and - has same precedence , so it will have right to left associativity. So I thought that any expression like 13 - - 14 + + 15 will be considered as 13 - (-14 + + 15) and output will be 12, but output is coming 42. Can anyone please explain the output?
A op B op Cis(A op B) op C, notA op (B op C).