Decimal literal in java

Java Programming Language Variables in java (Article) Variables in java (Program)

28119

This is a Java program that demonstrates the use of a decimal literal. In Java, a decimal literal is a sequence of digits that represents a whole number value in base 10.

The program declares an integer variable named decimal_value and assigns it the value 256. This value is a decimal literal that represents the decimal value 256.

The program then prints the value of decimal_value to the console using the System.out.println method. When run, the program will output the value of decimal_value, which is 256.

Program:

 public class DecimalLiteral {

  public static void main(String[] a) {
	  
    int decimal_value = 256; // decimal 256
    System.out.println(decimal_value);
    
  }

}

Output:

256
Press any key to continue . . .

Explanation:

In summary, this program demonstrates how to use a decimal literal to assign a value to an integer variable in Java.


This Particular section is dedicated to Programs only. If you want learn more about Java Programming Language. Then you can visit below links to get more depth on this subject.