Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #16152

Re: How to not use casting to invoke the methods of a List of objects

From Joerg Meier <joergmmeier@arcor.de>
Newsgroups comp.lang.java.programmer
Subject Re: How to not use casting to invoke the methods of a List of objects
Date 2012-07-20 17:45 +0200
Message-ID <1wvikyeajv4gw.1h99pyt4edcxc$.dlg@40tude.net> (permalink)
References <61dca380-4364-4713-aa27-e885f96632ea@googlegroups.com>

Show all headers | View raw


On Fri, 20 Jul 2012 06:58:49 -0700 (PDT), clusardi2k@aol.com wrote:

> The below start of replacement code fails because it skips through the list. There wasn't a good reason for me to finish the code! The loop can't even iterate the required number of loops.

>         Iterator <Route> it = objList.iterator();

>         int size = objList.size();

>         for (int i = 0;i < size; i++)
>         {
>            it.next();
>         }

That is not really how you use iterators. Proper way:

Iterator <Route> it = objList.iterator();

while (it.hasNext()) {
	it.next();
}

Liebe Gruesse,
		Joerg

-- 
Ich lese meine Emails nicht, replies to Email bleiben also leider
ungelesen.

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

How to not use casting to invoke the methods of a List of objects clusardi2k@aol.com - 2012-07-20 06:58 -0700
  Re: How to not use casting to invoke the methods of a List of objects markspace <-@.> - 2012-07-20 07:21 -0700
    Re: How to not use casting to invoke the methods of a List of objects clusardi2k@aol.com - 2012-07-20 08:09 -0700
  Re: How to not use casting to invoke the methods of a List of objects Joerg Meier <joergmmeier@arcor.de> - 2012-07-20 17:45 +0200
    Re: How to not use casting to invoke the methods of a List of objects Robert Klemme <shortcutter@googlemail.com> - 2012-07-20 18:03 +0200
      Re: How to not use casting to invoke the methods of a List of objects Joerg Meier <joergmmeier@arcor.de> - 2012-07-20 18:59 +0200
  Re: How to not use casting to invoke the methods of a List of objects Roedy Green <see_website@mindprod.com.invalid> - 2012-07-20 21:22 -0700
  Re: How to not use casting to invoke the methods of a List of objects Lew <noone@lewscanon.com> - 2012-07-21 23:34 -0700

csiph-web