Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Hexadecimal integer literal in Java
For Hexadecimal, the 0x or 0X is to be placed in the beginning of a number.
Note − Digits 10 to 15 are represented by a to f (A to F) in Hexadecimal
Here are some of the examples of hexadecimal integer literal declared and initialized as int.
int one = 0X123; int two = 0xABC;
Example
public class Demo {
public static void main(String []args) {
int one = 0X123;
int two = 0xABC;
System.out.println("Hexadecimal: "+one);
System.out.println("Hexadecimal: "+two);
}
}
Output
Hexadecimal: 291 Hexadecimal: 2748
Advertisements
