lundi 21 août 2017

Iterator and If

I got a little problem with my programm.

Iterator<MyString> it = globalSet.iterator();
Iterator<String> it2 = globalArray.iterator();



        while(it.hasNext() && it2.hasNext())
        {
            System.out.println(it2.next());
            if(it.next().getLine().contains(it2.next()) == true)
            {


                //it.remove();
            }

        }

If i disable the if clause my Output is correct and looks like this:

1;Trägertour 096;1410;Autotour 1N410;
2;Trägertour 097;1410;Autotour 1N410;
3;Trägertour 098;1410;Autotour 1N410;
4;Trägertour 099;1410;Autotour 1N410;
5;Trägertour 100;1410;Autotour 1N410;

But if the if clause is enabled my Output looks like this:

1;Trägertour 096;1410;Autotour 1N410;
3;Trägertour 098;1410;Autotour 1N410;
5;Trägertour 100;1410;Autotour 1N410;

So why?

Aucun commentaire:

Enregistrer un commentaire