How to Convert a Number to Hexadecimal in Java


In this example we will show the method to convert a number to hexadecimal in Java.

Source Code

package com.beginner.examples;

public class Num2Hexadecimal {
  public static void main(String[] args) {
    int num = 17;
    System.out.println(Integer.toHexString(num)); // convert a number to hexadecimal
  }
}

Output:

11

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments