I agree that this isn’t usually a good suggestion. It is available as a refactoring for when you might need an iterator, but by no means should the IDE “warn” about it. I think that is the current behaviour though. The line is not marked with a hint lightbulb unless I put the cursor on that line. So it’s not like it shows in the gutter as a warning like you would get for an unused private function or similar.
It appears to be the hint “Expand Enhanced For Loop” that you will find under “Suggestions” in the editor Hints panel. When I turn that off the”expand” hint, the suggestion changes to “Can use functional operations” which coverts the loop to this.dictionart.forEach(word -> {...}); Scott > On Nov 28, 2022, at 9:00 AM, John <jbarrow...@gmail.com> wrote: > > Hi, > > Quick one. I have just installed a vanilla Netbeans 15 and when I write a > line such as > > for (Word word : this.dictionary) {...} > > Netbeans offers me a Warning / Recommendation > > `Convert to for (Iterator...) {}' > > That, if chosen, converts my syntax to > > for (Iterator<Word> it = this.dictionary.iterator(); it.hasNext();) {...} > > This is a lot less readable to me and I therefore wanted to turn off this > hint. > > However, The <alt><ret> doesn’t offer the option to disable this hint and I > couldn’t find it in the Tools > Options > Editor > Hints (Java) list, > although I found lots of other nice hints that I have turned on! > > I found this on Stack Overflow > > https://stackoverflow.com/questions/24263479/netbeans-convert-to-for-iterator-suggestion > > But that was to do with which one is more efficient and I suspect that the > warning is due to the fact that the more verbose version is quicker if the > number of elements in the iterator is very large. > > Am I stuck with this, or is it that I just overlooked where the hint is in > the long list? > > > John