Java-Operator Associativity (Right to Left)

Operator associativity (Right to Left) The assignment(=) operators are also typically ‘right to left’ associative. Program Program Source public class Javaapp { public static void main(String[] args) { int a,b,c,d; a=b=c=d=10; System.out.println(“a = “+a); System.out.println(“b = “+b); System.out.println(“c = “+c); System.out.println(“d = “+d); } }

Java-Force Precedence

Force Precedence Parentheses( ) may be used to force precedence, if necessary. For example : int totel=5*(5+15)/2; Generally multiplication and division operation has a higher precedence than the addition operation. But, addition operation executing first. Because, addition operation covered by parentheses. Parentheses may be used to force precedence, if necessary. Program Program Source public class Javaapp { public … Read more…