diff --git a/checkstyle.xml b/checkstyle.xml index f6ad3c22..8424e07f 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -181,7 +181,7 @@ - + diff --git a/src/main/java/com/thealgorithms/ciphers/DES.java b/src/main/java/com/thealgorithms/ciphers/DES.java index 119ad697..8e44f091 100644 --- a/src/main/java/com/thealgorithms/ciphers/DES.java +++ b/src/main/java/com/thealgorithms/ciphers/DES.java @@ -8,7 +8,7 @@ package com.thealgorithms.ciphers; public class DES { private String key; - private String subKeys[]; + private String[] subKeys; private void sanitize(String key) { int length = key.length(); @@ -78,7 +78,7 @@ public class DES { for (i = 0; i < 56; i++) { permutedKey.append(originalKey.charAt(PC1[i] - 1)); } - String subKeys[] = new String[16]; + String[] subKeys = new String[16]; String initialPermutedKey = permutedKey.toString(); String C0 = initialPermutedKey.substring(0, 28), D0 = initialPermutedKey.substring(28); @@ -159,7 +159,7 @@ public class DES { return permutedString.toString(); } - private String encryptBlock(String message, String keys[]) { + private String encryptBlock(String message, String[] keys) { StringBuilder permutedMessage = new StringBuilder(); int i; for (i = 0; i < 64; i++) { @@ -184,8 +184,8 @@ public class DES { } // To decode, we follow the same process as encoding, but with reversed keys - private String decryptBlock(String message, String keys[]) { - String reversedKeys[] = new String[keys.length]; + private String decryptBlock(String message, String[] keys) { + String[] reversedKeys = new String[keys.length]; for (int i = 0; i < keys.length; i++) { reversedKeys[i] = keys[keys.length - i - 1]; } @@ -230,7 +230,7 @@ public class DES { for (i = 0; i < l; i += 64) { String block = message.substring(i, i + 64); String result = decryptBlock(block.toString(), subKeys); - byte res[] = new byte[8]; + byte[] res = new byte[8]; for (j = 0; j < 64; j += 8) { res[j / 8] = (byte) Integer.parseInt(result.substring(j, j + 8), 2); } diff --git a/src/test/java/com/thealgorithms/bitmanipulation/NonRepeatingNumberFinderTest.java b/src/test/java/com/thealgorithms/bitmanipulation/NonRepeatingNumberFinderTest.java index c5031d97..1addde05 100644 --- a/src/test/java/com/thealgorithms/bitmanipulation/NonRepeatingNumberFinderTest.java +++ b/src/test/java/com/thealgorithms/bitmanipulation/NonRepeatingNumberFinderTest.java @@ -13,11 +13,11 @@ class NonRepeatingNumberFinderTest { @Test void testNonRepeatingNumberFinder() { - int arr[] = {1, 2, 1, 2, 6}; + int[] arr = {1, 2, 1, 2, 6}; assertEquals(6, NonRepeatingNumberFinder.findNonRepeatingNumber(arr)); - int arr1[] = {1, 2, 1, 2}; + int[] arr1 = {1, 2, 1, 2}; assertEquals(0, NonRepeatingNumberFinder.findNonRepeatingNumber(arr1)); - int arr2[] = {12}; + int[] arr2 = {12}; assertEquals(12, NonRepeatingNumberFinder.findNonRepeatingNumber(arr2)); } } diff --git a/src/test/java/com/thealgorithms/greedyalgorithms/ActivitySelectionTest.java b/src/test/java/com/thealgorithms/greedyalgorithms/ActivitySelectionTest.java index 106237ca..a997c198 100644 --- a/src/test/java/com/thealgorithms/greedyalgorithms/ActivitySelectionTest.java +++ b/src/test/java/com/thealgorithms/greedyalgorithms/ActivitySelectionTest.java @@ -9,8 +9,8 @@ import org.junit.jupiter.api.Test; public class ActivitySelectionTest { @Test public void testActivitySelection() { - int start[] = {1, 3, 0, 5, 8, 5}; - int end[] = {2, 4, 6, 7, 9, 9}; + int[] start = {1, 3, 0, 5, 8, 5}; + int[] end = {2, 4, 6, 7, 9, 9}; ArrayList result = ActivitySelection.activitySelection(start, end); ArrayList expected = new ArrayList<>(Arrays.asList(0, 1, 3, 4)); @@ -20,8 +20,8 @@ public class ActivitySelectionTest { @Test public void testSingleActivity() { - int start[] = {1}; - int end[] = {2}; + int[] start = {1}; + int[] end = {2}; ArrayList result = ActivitySelection.activitySelection(start, end); ArrayList expected = new ArrayList<>(Arrays.asList(0)); @@ -31,8 +31,8 @@ public class ActivitySelectionTest { @Test public void testNoOverlap() { - int start[] = {1, 2, 3}; - int end[] = {2, 3, 4}; + int[] start = {1, 2, 3}; + int[] end = {2, 3, 4}; ArrayList result = ActivitySelection.activitySelection(start, end); ArrayList expected = new ArrayList<>(Arrays.asList(0, 1, 2)); diff --git a/src/test/java/com/thealgorithms/greedyalgorithms/FractionalKnapsackTest.java b/src/test/java/com/thealgorithms/greedyalgorithms/FractionalKnapsackTest.java index e481128d..34ec354b 100644 --- a/src/test/java/com/thealgorithms/greedyalgorithms/FractionalKnapsackTest.java +++ b/src/test/java/com/thealgorithms/greedyalgorithms/FractionalKnapsackTest.java @@ -8,24 +8,24 @@ public class FractionalKnapsackTest { @Test public void testFractionalKnapsackWithExampleCase() { - int weight[] = {10, 20, 30}; - int value[] = {60, 100, 120}; + int[] weight = {10, 20, 30}; + int[] value = {60, 100, 120}; int capacity = 50; assertEquals(240, FractionalKnapsack.fractionalKnapsack(weight, value, capacity)); } @Test public void testFractionalKnapsackWithZeroCapacity() { - int weight[] = {10, 20, 30}; - int value[] = {60, 100, 120}; + int[] weight = {10, 20, 30}; + int[] value = {60, 100, 120}; int capacity = 0; assertEquals(0, FractionalKnapsack.fractionalKnapsack(weight, value, capacity)); } @Test public void testFractionalKnapsackWithEmptyItems() { - int weight[] = {}; - int value[] = {}; + int[] weight = {}; + int[] value = {}; int capacity = 50; assertEquals(0, FractionalKnapsack.fractionalKnapsack(weight, value, capacity)); }