Java - Java Value Range

Description

Java Value Range

Demo

public class Variables {

  public static void main(String[] args) {
    /*/*from  w w w .  ja  v  a2s  . c  o m*/
     * Byte
     * Min: -128
     * Max: 127
     * Default: 0
     */
    byte myByte = 100;
    System.out.println("Byte Value: " + myByte);
    
    /*
     * Short
     * Min: -32,768
     * Max: 32,767
     * Default: 0
     */
    short myShort = 10000;
    System.out.println("Short Value: " + myShort);

    
    /*
     * int
     * Min: -2,147,483,648
     * Max: 2,147,483,647
     * Default: 0
     */
    int myInt = 467;
    System.out.println("Int Value is: " + myInt);
    
    /*
     * long
     * Min: -2^63
     * Max: 2^63 -1
     * Default: 0
     */
  long myLong = 81;
  System.out.println("Long value is:" + myLong);
  

    
    /*
     * float
     * Default: 0.0f
     */
  float myFloat = 0.07;
  System.out.println("Float value is:" + myFloat);

     
     /*
      * double
      * Default: 0.0d
      */
  double myDouble = 0.045;
  System.out.println("Double value is:" + myDouble);
     
     /*
      * boolean
      * false and true
      * Default: false
      */
    boolean myBoolean = true;
    System.out.println("Boolean value is:" + myBoolean);
     
     /*
      * char
      * Min: 0
      * Max: 65,535
      */
    char myChar = hello;
    System.out.println("Char value is" + myChar);
    
  }
}

Related Topic