Skip to content

Commit

Permalink
Update Challenge.java
Browse files Browse the repository at this point in the history
  • Loading branch information
VacancyIF authored Nov 23, 2023
1 parent 6789560 commit 5401698
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/java/com/bytelegend/Challenge.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ public static void main(String[] args) {
}

public static Object firstOrNull(Object[] array) {
return array[1];
if (array.length == 0) {
return null;
}
return array[0];
}

public static Object lastOrNull(Object[] array) {
return array[array.length];
if (array.length == 0) {
return null;
}
return array[array.length - 1];
}
}

0 comments on commit 5401698

Please sign in to comment.