From c31c39a08e658ebf5218864cf1f6ef7658039ef2 Mon Sep 17 00:00:00 2001 From: Abhijay Kumar Date: Tue, 28 May 2019 17:45:32 +0530 Subject: [PATCH] Removed usage of BigInteger constructor for constants --- src/main/java/com/conversions/BinaryToHexadecimal.java | 2 +- src/main/java/com/conversions/DecimalToHexadecimal.java | 2 +- src/main/java/com/conversions/DecimalToOctal.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/conversions/BinaryToHexadecimal.java b/src/main/java/com/conversions/BinaryToHexadecimal.java index fc891570..c7810f11 100644 --- a/src/main/java/com/conversions/BinaryToHexadecimal.java +++ b/src/main/java/com/conversions/BinaryToHexadecimal.java @@ -36,7 +36,7 @@ public class BinaryToHexadecimal { String hex = ""; int currentBit; - BigInteger tenValue = new BigInteger("10"); + BigInteger tenValue = BigInteger.valueOf(10); while (binary.compareTo(BigInteger.ZERO) != 0) { // to store decimal equivalent of number formed by 4 decimal digits int code4 = 0; diff --git a/src/main/java/com/conversions/DecimalToHexadecimal.java b/src/main/java/com/conversions/DecimalToHexadecimal.java index e0e9360d..0c812f52 100644 --- a/src/main/java/com/conversions/DecimalToHexadecimal.java +++ b/src/main/java/com/conversions/DecimalToHexadecimal.java @@ -4,7 +4,7 @@ import java.math.BigInteger; public class DecimalToHexadecimal { private static final char[] hexChars = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; - private static final BigInteger valueHex = new BigInteger("16"); + private static final BigInteger valueHex = BigInteger.valueOf(16); /** * This method converts and decimal number to a Hexadecimal number diff --git a/src/main/java/com/conversions/DecimalToOctal.java b/src/main/java/com/conversions/DecimalToOctal.java index 6ab6e72b..64542298 100644 --- a/src/main/java/com/conversions/DecimalToOctal.java +++ b/src/main/java/com/conversions/DecimalToOctal.java @@ -4,7 +4,7 @@ import java.math.BigInteger; public class DecimalToOctal { private static final char[] octalChars = {'0', '1', '2', '3', '4', '5', '6', '7'}; - private static final BigInteger valueOctal = new BigInteger("8"); + private static final BigInteger valueOctal = BigInteger.valueOf(8); /** * This method converts and decimal number to a octal number