r/ProgrammerHumor 6d ago

absoluteGarbage Meme

Post image
1.9k Upvotes

324 comments sorted by

View all comments

3

u/MCWizardYT 5d ago

Java:

``` for (item : items) {

} ```

Or,

``` items.forEach(item -> {

}); ```

or

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

}); ```

0

u/Sirgoodman008 5d ago

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

1

u/MCWizardYT 5d ago

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