Mathematical rules dictate that multiplication takes precedence over addition. It’s called BODMAS. Somehow the Java folks don’t seem to agree. But then maybe you could give me a better explanation for this anomaly?
package com.twisters;
public class MulOrAdd {
public static void main(String[] args) {
int x=5;
x *= 5+2;
System.out.println("Value of X is : "+x);
}
}
Got an answer? Why don’t you leave it here.
No comments:
Post a Comment
Solution for this question?