1 2 3 4 5 6 7 8 9 10 |
class test{ public static void main(String ... arg){ int length = arg.length; int sum = 0; for(String i : arg) sum+=Integer.parseInt(i); System.out.println("Arithmetic Mean of your numbers is : " + sum/length); } } |
Discussion
In above code sample we have not enclosed sum/length into Parentheses but in some programs we have enclosed arithmetic calculations into parentheses. It is because /,*,% are not overloaded while + is overloaded and that’s why (-) will also be trouble in situations where (+) precedes (-) in expression. While if (-) precedes (+) there would be not any trouble.