Answers for "java convert hex to byte"

5

Java convert hex to decimal

public class ConvertHexToDecimal
{
   public static void main(String[] args)
   {
      String strHex = "b";
      int decimal = Integer.parseInt(strHex, 16);
      System.out.println("Decimal number : " + decimal);
   }
}
Posted by: Guest on December-29-2020
0

Hexadecimal to Binary conversion with java

public static int hexadecimalToBinary(String hex) {
        // Declaring Hexadecimal variable
        String binary = "";

/**
 * Converting the Hexadecimal value to Binary Equivalent
 * First convert the Hexadecimal to Decimal Equivalent
 * Then to Binary Equivalent
 */
  
        // Converting Binary to decimal
        int number = Integer.parseInt( hex, 16 );
        // Converting Decimal Equivalent to Hexadecimal
        binary = Integer.toBinaryString( number );

        // Returning the Hexadecimal value
        return binary;
    }
Posted by: Guest on October-19-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language