Mega Code Archive

 
Categories / Java Tutorial / Data Type
 

Integer Calculations

The basic operators in calculations are +, -, *, and /. They have the usual meanings: add, subtract, multiply, and divide, respectively. Using parentheses in arithmetic calculations to change the sequence of operations. public class MainClass{   public static void main(String[] argv){     int a = (20 - 3) * (3 - 9) / 3;     int b = 20 - 3 * 3 - 9 / 3;              System.out.println(a);     System.out.println(b);   } } -34 8