Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

public class Main {
    public static void main(String[] args) {
        int i = 8;
        int j = -5;
        System.out.println("Absolute value of " + i + " is :" + Math.abs(i));
        System.out.println("Absolute value of " + j + " is :" + Math.abs(j));

        float f1 = 1.40f;
        float f2 = -5.28f;
        System.out.println("Absolute value of " + f1 + " is :" + Math.abs(f1));
        System.out.println("Absolute value of " + f2 + " is :" + Math.abs(f2));

        double d1 = 3.324;
        double d2 = -9.324;
        System.out.println("Absolute value of " + d1 + " is :" + Math.abs(d1));
        System.out.println("Absolute value of " + d2 + " is :" + Math.abs(d2));

        long l1 = 3L;
        long l2 = -4L;
        System.out.println("Absolute value of " + l1 + " is :" + Math.abs(l1));
        System.out.println("Absolute value of " + l2 + " is :" + Math.abs(l2));
    }
}