Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Improve readability in LinearSearch by using local variable
  • Loading branch information
KadambariSuresh committed Apr 7, 2026
commit 5da90c9a90c0cd36af3bdf5e4d60683ff499c071
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public <T extends Comparable<T>> int find(T[] array, T value) {
}

for (int i = 0; i < array.length; i++) {
if (array[i] != null && array[i].compareTo(value) == 0) {
T currentElement = array[i];
if (currentElement != null && currentElement.compareTo(value) == 0) {
return i;
}
}
Expand Down
Loading