![]() |
VOOZH | about |
The lastIndexOfSubList() method of Java Collections is used in ArrayList Collection. An ArrayList is a data structure that can sequentially store data with multiple data types.
We can create an array list by using the syntax:
List<datatype> data = new ArrayList<>();
where,
The lastIndexOfSubList() method is used to get the starting position of the last occurrence of the specified target list within the specified source list.
Syntax:
public static int lastIndexOfSubList(List<?> first, List<?> last)
where,
Return Type: It will return the starting position of the last occurrence of the specified target list within the specified source list. It will return -1 if there are no occurrences in the given list.
Example 1:
Java program to check source list in the last list
2
Example 2:
-1