Primitive types of Java with their respective encoding representations and range of values. - Java Language Basics

Java examples for Language Basics:Variable

Introduction

All primitive types of Java are manipulated by value.

Type Name Size Value
Boolean boolean 1 bit true or false
Character char 2 bytes UNICODE
Integer byte1 byte [-128, 128]
Integer short 2 bytes [-32768, 32767]
Integer int4 bytes [-2^31 = -2147483648, 2^31 - 1 = 21477483647]
Integer long 8 bytes [-2^63 = -9223372036854775808, 2^63 - 1 = 9223372036854775807]
Real float 4 bytes [1.40129846432481707e - 45f, 3.40282346638528860e + 38f]
Real double8 bytes [2.2250738585072014e - 308d, 1.79769313486231570e + 308d]

Demo Code


public class Main{
    public static void main(String[] args) {
        System.out.print("Volume of the box (in cubic meter):");
        System.out.println(0.5 * 1 * 0.2);
    }/*ww  w . j  a va 2 s  . co m*/
}

Result


Related Tutorials