You can use Enhanced for loop to iterate over a vector
for (Integer digit : digits) {
}
We also know the size of the vector, we can write a for loop using vector.size()
.
for(int index = 0; index < digits.size(); index++) {
System.out.println(digits.get(index));
}
You can also follow the other ways given here
1
solved What are different ways to iterate through a vector, other than the iterator object?