Java Tutorial

Runtime
java 21.0.12
Files
60 files · 24 KB
Runs
50 runs
Published
sessionThree/ArithmeticOperators.java500 B
package sessionThree;​public class ArithmeticOperators {    public static void main(String[] args) {        System.out.println(7 / 2);      // 3        System.out.println(7.0 / 2);    // 3.5        System.out.println(7 / 2.0);    // 3.5        System.out.println(1 / 3);      // 0        int total = 250, count = 3;        double avg = total / count;     // 83.0 (division happened in int first!)        System.out.println(avg);​        int a = 7 /2;        System.out.println(a);    }}​