In this tutorial, we will see “How to convert Binary to HexaDecimal using Java?”
How to convert Binary to hexadecimal number in java
Java – How to convert Binary to Hexadecimal Number? Share on X
/**
* Using Java, Convert Binary to HexaDecimal Number
* @author Deepak Verma
*
*/
public class Convert_Binary_To_HexaDecimal_Java_Example {
public static void main(String[] args) {
String binaryValue = "110101111";
System.out.println("Hexadecimal value of Binary ("+binaryValue+") is: "+binaryToHexadecimal(binaryValue));
}
public static String binaryToHexadecimal(String binaryValue) {
return Integer.toHexString(Integer.parseInt(binaryValue, 2));
}
}
Output:
Hexadecimal value of Binary (110101111) is: 1af
How to convert Binary to hexadecimal number in java
Java – How to convert Binary to Hexadecimal Number? Share on X
Do you like this Post? – then check my other helpful posts:
- Convert a Stream to a List in Java 8
- Stream maptoint in Java 8 with examples
- Double the numbers of specified ArrayList using Streams
- Double the even / odd numbers of a specified ArrayList using Streams
- How to check if Number is Prime or not using Streams
- Retrieve Even/Odd Numbers within the Range using Java 8 Streams
- How to add/sum up the ArrayList integers using Java8 Streams
- Generate Prime Numbers in Java 8 using Streams
- Comparator example – Collections sort with/without Lambda in Java 8
- How to pass function as a parameter in a method in Java 8?
- Remove duplicates from ArrayList in Java 8
- ForEach examples for Map/List in Java 8
Other Useful References: