mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-18 17:31:13 +08:00
@ -1,18 +1,13 @@
|
||||
import java.lang.StringBuilder;
|
||||
import java.util.*;
|
||||
import java.util.Scanner;
|
||||
import javax.swing.*;
|
||||
|
||||
public class HexaDecimalToBinary {
|
||||
|
||||
|
||||
private final int LONG_BITS = 8;
|
||||
|
||||
public void convert(String numHex) {
|
||||
//String a HexaDecimal:
|
||||
// String a HexaDecimal:
|
||||
int conHex = Integer.parseInt(numHex, 16);
|
||||
//Hex a Binary:
|
||||
// Hex a Binary:
|
||||
String binary = Integer.toBinaryString(conHex);
|
||||
//Presentation:
|
||||
// Presentation:
|
||||
System.out.println(numHex + " = " + completeDigits(binary));
|
||||
}
|
||||
|
||||
@ -27,7 +22,7 @@ public class HexaDecimalToBinary {
|
||||
|
||||
//Testing Numbers:
|
||||
String[] hexNums = {"1", "A1", "ef", "BA", "AA", "BB",
|
||||
"19", "01", "02", "03", "04"};
|
||||
"19", "01", "02", "03", "04"};
|
||||
HexaDecimalToBinary objConvert = new HexaDecimalToBinary();
|
||||
|
||||
for (String num : hexNums) {
|
||||
|
Reference in New Issue
Block a user