Afficher un message
Vieux 04/04/2008, 13h25   #19
Markus Moll
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Iterators in Java and C++

Hi

Razii wrote:

> If the problem is that "You should be able to access the object
> without advancing the iterator", where am I calling next in this
> syntax.


Easy...

> int[] nums = { 1, 2, 3, 4, 5, 6 };
>
> for(int n : nums) {

^^^^^^^^^^^^

Here...

> System.out.println(n);
> }
>
> Or
>
> List list = getList();
>
> for (Object element : list) {

^^^^^^^^^^^^^^^^^^^^^
.... and here.

> out.println(element);
>
> // Do something else with this element
> }


Markus

  Réponse avec citation
 
Page generated in 0,06577 seconds with 9 queries