Reputation: 127
I am iterating a Collection using foreach, I am using intelliJ IDE.
queue.forEach(s->{
System.out.println(s);
});
I am getting warning here that "Can be replaced with method reference.."
can anyone suggest how can I use method reference here?
Upvotes: 4
Views: 9104
Reputation: 27018
System.out::println
This should do
queue.forEach(System.out::println);
Upvotes: 8