添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Use the + Integer.toHexString() method in Java to convert integer to hexadecimal.

Let’s say the following is our integer.

int val = 768;

Let us convert it to a hexadecimal value.

Integer.toHexString(val)

The following is the final example with the output.

Example

Live Demo

public class Demo {
    public static void main(String[] args) {
       int val = 768;
       // integer
       System.out.println("Integer: "+val);
       // hex
       System.out.println("Hex String = " + Integer.toHexString(val));
}

Output

Integer: 768
Hex String = 300
  • Related Articles
  • Java Program to convert decimal integer to hexadecimal number
  • Convert decimal integer to hexadecimal number in Java
  • Java Program to Convert Octal to Hexadecimal
  • Java Program to Convert Hexadecimal to Binary
  • Java Program to convert hexadecimal number to decimal number
  • Java Program to convert integer to boolean
  • Java Program to convert boolean to integer
  • Java program to convert integer to octal
  • Convert Hexadecimal to Octal in Java?
  • How to convert an integer to a hexadecimal string in Python?
  • Golang Program to convert Decimal to Hexadecimal
  • Golang Program to convert Hexadecimal to Decimal
  • Swift Program to convert Hexadecimal to Decimal
  • Swift Program to convert Decimal to Hexadecimal
  • Haskell Program to Convert Data to Hexadecimal
  • Kickstart Your Career

    Get certified by completing the course

    Get Started

    Tutorials Point is a leading Ed Tech company striving to provide the best learning material on technical and non-technical subjects.

    About us