Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Finds the index of the last occurrence of <code>target</code> in <code>source</code>
- * @param source the array that we are checking.
- * @param target the element which index we are looking for
- * @return integer index of target
- *
- * @author Dimitar Naydenov
- */
- public static int lastIndexOf(int[] source, int target) {
- if (source.length == 0){
- return -1;
- }
- for (int i = source.length-1; i >= 0 ; i--) {
- if (source[i] == target){
- return i;
- }
- }
- return -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement