Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Java by (6.5k points)
I'm trying to work with iterators, I would like to know what exactly would delete an element.

1 Answer

0 votes
by (11.3k points)

Using iterators has many benefits. In your case, to remove the current element, the one that the iterator is pointing towards, you can use the remove() method. Keep in mind though, if the remove() method is not preceded by a next() function, an IllegalStateException will be thrown. 

If you're looking to learn java, you can experiment with element manipulation with Arrays and iterators to get a better grasp of the concepts. 

Related questions

0 votes
1 answer
0 votes
1 answer
asked Jul 20, 2019 in Java by Anvi (10.2k points)
0 votes
1 answer
0 votes
0 answers

Browse Categories

...