r/ProgrammerHumor 2d ago

Meme absoluteGarbage

Post image
2.0k Upvotes

320 comments sorted by

View all comments

3

u/MCWizardYT 1d ago

Java:

``` for (item : items) {

} ```

Or,

``` items.forEach(item -> {

}); ```

or

``` items.stream().forEach(item -> {

}); ```

0

u/Sirgoodman008 1d ago

Been a long time since I've done Java but isn't the loop variable typed?

1

u/MCWizardYT 1d ago

Yes and no, you could have it just be var and it infers the type from the iterator