Since the Size of the list is 6, so indexes are 0,1,2,3,4,5 (which is value of i in this case)
You are always increasing the value of i by 1 and when it is i = 5, it is throwing IndexOutOfBoundsException.
As a fix you can do
if (i < 5 && current.equals(listaTags.get(i + 1))) {...}
More Related Contents:
- ArrayList is reinitialising when a method is called
- why is it that we can’t use ArrayList.get(-1) to get the last element of the ArrayList in java? it works in python though [closed]
- How to arrange the datas to display in array by given string of days in java?
- ArrayList Data Structure – Daily Temperature
- I am new in using ArrayLists. Array Out of Bounds, Array seems to be empty, but have been adding Strings to it already
- How to sort a List/ArrayList?
- Convert list to array in Java [duplicate]
- How to find an object in an ArrayList by property
- In Java how do you sort one list based on another?
- How to iterate an ArrayList inside a HashMap using JSTL?
- Sorting arraylist in alphabetical order (case insensitive)
- How can I create an Array of ArrayLists?
- ArrayList’s custom Contains method
- Get specific ArrayList item
- Best way to create a hashmap of arraylist
- How to remove element from ArrayList by checking its value?
- Check if an ArrayList contains every element from another ArrayList (or Collection)
- How do I populate a JComboBox with an ArrayList?
- How to find the length of an array list? [duplicate]
- How can I slice an ArrayList out of an ArrayList in Java?
- How can I convert ArrayList to ArrayList?
- Trying to find all occurrences of an object in Arraylist, in java
- casting Arrays.asList causing exception: java.util.Arrays$ArrayList cannot be cast to java.util.ArrayList
- Why can’t you have a “List” in Java? [duplicate]
- How can I create an array in Kotlin like in Java by just providing a size?
- Time complexity of contains(Object o), in an ArrayList of Objects
- Java Generic with ArrayList
- How to remove specific object from ArrayList in Java?
- Java ArrayList how to add elements at the beginning
- Vector vs Collections.synchronizedList(ArrayList)