Ads

How to print different type of values in Java ? | JAVA PROGRAMMING | JAVA LANGUAGE

In this program, we are going to declare and define some of the different type of variables and then will print them using System.out.println() method.


 class j2 {

    public static void main(String args[]) {

        int num;

        float b;

        char c;

        String s;


        //integer

        num = 100;

        //float

        b = 1.234 f;

        //character

        c = 'A';

        //string

        s = "Hello Java";


        System.out.println("Value of num: " + num);

        System.out.println("Value of b: " + b);

        System.out.println("Value of c: " + c);

        System.out.println("Value of s: " + s);

    }

}

Post a Comment

0 Comments