We can convert decimal to hexadecimal in java using Integer.toHexString() method or custom logic.
Java Decimal to Hex conversion: Integer.toHexString()
The Integer.toHexString() method converts decimal to hexadecimal. The signature of toHexString() method is given below:
public static String toHexString(int decimal)
Let's see the simple example of converting decimal to binary in java.
Output:
Java Decimal to Hex conversion: Custom Logic
We can convert decimal to hex in java using custom logic.
Output: