Hexadecimal literal of type long

Java Programming Language / Variables in java

1759

This is a Java program that demonstrates the use of a hexadecimal literal as a long type variable. In Java, a long is a data type that represents a 64-bit signed integer.

The program declares a long variable named hexLongValue and assigns it the value 0x0FFL. This value is a hexadecimal literal that represents the decimal value 255. The L at the end of the literal indicates that it is a long type.

The program then prints the value of hexLongValue to the console using the System.out.println method. When run, the program will output the decimal value of the hexadecimal literal, which is 255.

Program:

 public class HexadecimalLiteralAsLong {

  public static void main(String[] a) {
    long hexLongValue = 0x0FFL;
    System.out.println(hexLongValue);
  }

}

Output:

255
Press any key to continue . . .

Explanation:

In summary, this program demonstrates how to use a hexadecimal literal as a long type 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.