6 Replies - 1058 Views - Last Post: 11 July 2012 - 04:15 AM Rate Topic: -----

#1 Eldarmk2  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 08-July 12

How to get the index

Posted 10 July 2012 - 10:57 PM

Hi2all!
Can some one help me out a bit, im trying to find a index of an object in a list under a iterator;
somwehre in the net i found some thing like that it.nextIndex()-1; but im using the iterator from java utility and it doesnt have nextIndex();
How to get the index of the object on which the iterator is pointing ?
Is This A Good Question/Topic? 0
  • +

Replies To: How to get the index

#2 fromTheSprawl  Icon User is offline

  • Wandering Like A Fool
  • member icon

Reputation: 509
  • View blog
  • Posts: 2,041
  • Joined: 28-December 10

Re: How to get the index

Posted 10 July 2012 - 11:47 PM

Use a counter variable inside your iteration?
Was This Post Helpful? 0
  • +
  • -

#3 Eldarmk2  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 08-July 12

Re: How to get the index

Posted 11 July 2012 - 12:41 AM

View PostfromTheSprawl, on 10 July 2012 - 11:47 PM, said:

Use a counter variable inside your iteration?

Oh ... yeh that would help, thanks!
Was This Post Helpful? 0
  • +
  • -

#4 fromTheSprawl  Icon User is offline

  • Wandering Like A Fool
  • member icon

Reputation: 509
  • View blog
  • Posts: 2,041
  • Joined: 28-December 10

Re: How to get the index

Posted 11 July 2012 - 12:58 AM

No problem dude! Just tell us if something goes wrong or something. :)
Was This Post Helpful? 0
  • +
  • -

#5 Eldarmk2  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 08-July 12

Re: How to get the index

Posted 11 July 2012 - 01:16 AM

View PostfromTheSprawl, on 11 July 2012 - 12:58 AM, said:

No problem dude! Just tell us if something goes wrong or something. :)

I hope soon i can help or atleast post some intresting progs
Was This Post Helpful? 0
  • +
  • -

#6 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8066
  • View blog
  • Posts: 31,310
  • Joined: 06-March 08

Re: How to get the index

Posted 11 July 2012 - 03:53 AM

If you need the index, simply don't use an Iterator

for(int index = 0; index < list.size(); ++index)

will do the job as well and explains better what you try to do
Was This Post Helpful? 2
  • +
  • -

#7 Eldarmk2  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 08-July 12

Re: How to get the index

Posted 11 July 2012 - 04:15 AM

View Postpbl, on 11 July 2012 - 03:53 AM, said:

If you need the index, simply don't use an Iterator

for(int index = 0; index < list.size(); ++index)

will do the job as well and explains better what you try to do

Oh yes thats it! It will do the job ! thanks!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1