- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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
- Related Articles
- Hexadecimal literal of type long in Java
- Convert decimal integer to hexadecimal number in Java
- Java Program to convert integer to hexadecimal
- Java Program to convert decimal integer to hexadecimal number
- Integer literal in C/C++ (Prefixes and Suffixes)
- Is null a literal in Java?
- Floating-point hexadecimal in Java
- How to convert an integer to a hexadecimal string in Python?
- What is Java String literal?
- Pattern LITERAL field in Java with examples
- How to convert an integer to hexadecimal and vice versa in C#?
- Parse and format to hexadecimal in Java
- Map an integer from decimal base to hexadecimal with custom mapping JavaScript
- Formatter Specifier for Octal and Hexadecimal in Java
- Convert a byte to hexadecimal equivalent in Java

Advertisements