Java count same elements in arraylist. All you're doing is fetching the value from the ArrayList.