diff --git a/src/main/java/com/thealgorithms/ciphers/AES.java b/src/main/java/com/thealgorithms/ciphers/AES.java index 65c6ce79..c5cb286c 100644 --- a/src/main/java/com/thealgorithms/ciphers/AES.java +++ b/src/main/java/com/thealgorithms/ciphers/AES.java @@ -2438,16 +2438,16 @@ public class AES { public static BigInteger[] keyExpansion(BigInteger initialKey) { BigInteger[] roundKeys = { initialKey, - new BigInteger("0"), - new BigInteger("0"), - new BigInteger("0"), - new BigInteger("0"), - new BigInteger("0"), - new BigInteger("0"), - new BigInteger("0"), - new BigInteger("0"), - new BigInteger("0"), - new BigInteger("0"), + BigInteger.ZERO, + BigInteger.ZERO, + BigInteger.ZERO, + BigInteger.ZERO, + BigInteger.ZERO, + BigInteger.ZERO, + BigInteger.ZERO, + BigInteger.ZERO, + BigInteger.ZERO, + BigInteger.ZERO, }; // initialize rcon iteration diff --git a/src/main/java/com/thealgorithms/ciphers/RSA.java b/src/main/java/com/thealgorithms/ciphers/RSA.java index fcce53cb..08f4e198 100644 --- a/src/main/java/com/thealgorithms/ciphers/RSA.java +++ b/src/main/java/com/thealgorithms/ciphers/RSA.java @@ -63,7 +63,7 @@ public class RSA { publicKey = BigInteger.valueOf(3L); while (m.gcd(publicKey).intValue() > 1) { - publicKey = publicKey.add(BigInteger.valueOf(2L)); + publicKey = publicKey.add(BigInteger.TWO); } privateKey = publicKey.modInverse(m); diff --git a/src/main/java/com/thealgorithms/maths/KaprekarNumbers.java b/src/main/java/com/thealgorithms/maths/KaprekarNumbers.java index 2d15dc4f..a932dc77 100644 --- a/src/main/java/com/thealgorithms/maths/KaprekarNumbers.java +++ b/src/main/java/com/thealgorithms/maths/KaprekarNumbers.java @@ -10,7 +10,7 @@ public class KaprekarNumbers { digits and sum of these parts is equal to the original number. */ // Provides a list of kaprekarNumber in a range - public static ArrayList kaprekarNumberInRange(long start, long end) + public static List kaprekarNumberInRange(long start, long end) throws Exception { long n = end - start; if (n < 0) throw new Exception("Invalid range"); @@ -26,12 +26,12 @@ public class KaprekarNumbers { // Checks whether a given number is Kaprekar Number or not public static boolean isKaprekarNumber(long num) { String number = Long.toString(num); - BigInteger originalNumber = new BigInteger(number); + BigInteger originalNumber = BigInteger.valueOf(num); BigInteger numberSquared = originalNumber.multiply(originalNumber); if (number.length() == numberSquared.toString().length()) { return number.equals(numberSquared.toString()); } else { - BigInteger leftDigits1 = new BigInteger("0"); + BigInteger leftDigits1 = BigInteger.ZERO; BigInteger leftDigits2; if (numberSquared.toString().contains("0")) { leftDigits1 = diff --git a/src/test/java/com/thealgorithms/maths/KaprekarNumbersTest.java b/src/test/java/com/thealgorithms/maths/KaprekarNumbersTest.java index 98c7baa2..326c1a9a 100644 --- a/src/test/java/com/thealgorithms/maths/KaprekarNumbersTest.java +++ b/src/test/java/com/thealgorithms/maths/KaprekarNumbersTest.java @@ -2,7 +2,8 @@ package com.thealgorithms.maths; import static org.junit.jupiter.api.Assertions.*; -import java.util.ArrayList; +import java.util.List; + import org.junit.jupiter.api.Test; public class KaprekarNumbersTest { @@ -50,7 +51,7 @@ public class KaprekarNumbersTest { @Test void testForRangeOfNumber() { try { - ArrayList rangedNumbers = KaprekarNumbers.kaprekarNumberInRange( + List rangedNumbers = KaprekarNumbers.kaprekarNumberInRange( 1, 100000 );