Community
Participate
Working Groups
Iterator iterator = new ArrayList().iterator(); while (iterator.hasNext()) { iterator.next().toString(); } iterator = new ArrayList().iterator(); while (iterator.hasNext()) { iterator.next().toString(); } . select 'iterator.next' and invoke refactor>extract local variable. The result is : Iterator iterator = new ArrayList().iterator(); Object next = iterator.next(); while (iterator.hasNext()) { next.toString(); } iterator = new ArrayList().iterator(); while (iterator.hasNext()) { next.toString(); } this is no the equivalent of the original code. I don't think it's a direct dup of bug 48231 or bug 35788, the problem in those cases seems to be the lack of blocks. In this case, refactoring works fine if I have only one loop.
*** This bug has been marked as a duplicate of 27740 ***