What are the primitive data types in Java

1 Answer

0 votes
public class MyClass {
    public static void main(String args[]) {
        byte b = 2;
        System.out.println("Byte: " + b);

        short s = 12;
        System.out.println("short: " + s);

        int i = 8782;
        System.out.println("Integer: " + i);

        long l = 94847;
        System.out.println("Long: " + l);

        float f = 3.14f;
        System.out.println("Float: " + f);

        double d = 9477234.987;
        System.out.println("Double: " + d);

        char ch = 'z';
        System.out.println("Char: " + ch);

        boolean bl = true;
        System.out.println("Boolean: " + bl);
    }
}




/*
run:

Byte: 2
short: 12
Integer: 8782
Long: 94847
Float: 3.14
Double: 9477234.987
Char: z
Boolean: true

*/

 



answered Mar 2, 2021 by avibootz

Related questions

1 answer 196 views
1 answer 293 views
1 answer 252 views
1 answer 227 views
1 answer 236 views
1 answer 244 views
1 answer 213 views
...