Skip to content

Commit 0ad5d90

Browse files
SenrianpenggaolaiOpenClaw BotDenizAltunkapan
authored
fix: remove malformed javadoc to fix -Werror build failure (#7393) (#7394)
* fix: prevent NPE when array contains null elements When searching for a non-null key in an array that contains null elements, the sentinel linear search would throw a NullPointerException because it called array[i].compareTo(key) without checking if array[i] is null. Added null check for array[i] in the while loop condition to prevent NPE and return the correct index when array elements themselves are null. Issue: #7318 (related) * fix: remove malformed @author javadoc in AnyBaseToAnyBase (issue #7393) * fix: remove malformed javadoc in ReverseString (part of issue #7393) --------- Co-authored-by: OpenClaw Agent <agent@openclaw.ai> Co-authored-by: OpenClaw Bot <fix-bug@openclaw.ai> Co-authored-by: Deniz Altunkapan <deniz.altunkapan@outlook.com>
1 parent b3e31b5 commit 0ad5d90

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

src/main/java/com/thealgorithms/conversions/AnyBaseToAnyBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* <p>
44
* Time Complexity: O(n) [or appropriate complexity]
55
* Space Complexity: O(n)
6-
* * @author Reshma Kakkirala
6+
* @author Reshma Kakkirala
77
*/
88
package com.thealgorithms.conversions;
99

src/main/java/com/thealgorithms/searches/SentinelLinearSearch.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ public <T extends Comparable<T>> int find(T[] array, T key) {
6565

6666
int i = 0;
6767
// Search without bound checking since sentinel guarantees we'll find the key
68-
while (array[i].compareTo(key) != 0) {
68+
// Null check for array element to prevent NPE when array contains null elements
69+
while (array[i] != null && array[i].compareTo(key) != 0) {
6970
i++;
7071
}
7172

src/main/java/com/thealgorithms/strings/ReverseString.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public static String reverse3(String string) {
6262
/**
6363
* Reverses the given string using a stack.
6464
* This method uses a stack to reverse the characters of the string.
65-
* * @param str The input string to be reversed.
65+
* @param str The input string to be reversed.
6666
* @return The reversed string.
6767
*/
6868
public static String reverseStringUsingStack(String str) {

0 commit comments

Comments
 (0)