On 04/28/2016 04:08 PM, Attila Szegedi wrote:
On Thu, Apr 28, 2016 at 3:52 PM, Aleksey Shipilev <
aleksey.shipi...@oracle.com> wrote:

  *) next(): Missing braces in throw new NSEE() block;
  *) next(): Why loading this.a into local?

I agree with Aleksey but I'd go as far as to say that not only this.a is
unnecessary, but i as well. The body of next() looks too elaborate. This
seems equivalent and concise:

   if (cursor >= a.length) {
       throw new NoSuchElementException();
   }
   return a[cursor++];

Attila.

...except that your variant can throw ArrayIndexOutOfBoundsException (if used inappropriately) and Tagir's can't.

(this.a is final and doesn't need to be loaded into local).

Regards, Peter

Reply via email to