• Post Reply Bookmark Topic Watch Topic
  • New Topic

ListIterator --> nextIndex and previousIndex  RSS feed

 
harsha karanam
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

When we use the next method of the ListIterator interface it returns the element and moves to the next position

in the case of the nextIndex or previousIndex method it returns the element position but not moving the next position , then in real time scenario when is the nextIndex method useful?
 
harsha karanam
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correction in the topic heading it has to be previousIndex

[moderator edit: correction to subject text made]
 
Campbell Ritchie
Marshal
Posts: 56562
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you looked in the documentation for those two methods?
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sreeharsha Karanam wrote:then in real time scenario when is the nextIndex method useful?

To paraphrase Iñigo Montoya: "You keep using that phrase; it doesn't actually mean what you think it means." -- again, you probably mean "real-world" not "real time".

 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the documentation that Campbell cited, in particular, look at the add() method documentation because it mentions how it affects the values that nextIndex and previousIndex return.

I have never had occasion to use these methods myself but in practical terms, I would guess that they're there so that you can check them first and avoid exceptions in situations where calls to add() and remove() can be interleaved with calls to next() and previous().
 
harsha karanam
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes i have looked in to the documentation , during the iteration of the list using the method next it returns the element and moves to next position but in the case of nextIndex it returns the index position but it does not move the position
 
harsha karanam
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu Lacar wrote:
sreeharsha Karanam wrote:then in real time scenario when is the nextIndex method useful?

To paraphrase Iñigo Montoya: "You keep using that phrase; it doesn't actually mean what you think it means." -- again, you probably mean "real-world" not "real time".



thanks for the correction
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sreeharsha Karanam wrote:thanks for the correction

No problem. You could also say "In terms of practical usage, ... " or "In actual practice, ..." or simply, "In practice, ..."
 
Dave Tolls
Ranch Foreman
Posts: 3065
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu Lacar wrote:
To paraphrase Iñigo Montoya:

"You killed my father. Prepare to die."?

Junilu Lacar wrote:
"You keep using that phrase; it doesn't actually mean what you think it means."


Oh yes, that makes a bit more sense.
You had me worried there.
;)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!