Integer Decimal(base ten) Literals

What are Literals

A constant value is a literal representation of a data type. For example, the following code defines integer literals:


public class Main{
  public static void main(String[] argv){
    int a = 100;
  }
}

Any whole number value is an integer literal, for examples, 1, 2, 3, 100, 102. The following code defines a byte type variable and assign 0 integer literal to it.


public class Main {
  public static void main(String args[]) {
    byte b = 0;

    System.out.println("b is " + b);
  }
}

The output generated by this program is shown here:


b is 0
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.