Skip to content

Commit

Permalink
Update Challenge.java (#125)
Browse files Browse the repository at this point in the history
Update Challenge.java (#125)

Co-authored-by: VacancyIF <[email protected]>
  • Loading branch information
ByteLegendBot and VacancyIF committed Nov 23, 2023
2 parents ea0afeb + 60b665e commit 22c858a
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 22c858a

Please sign in to comment.