Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Static method reference example.
public class StaticMethodReference {
public static void main(String[] args) {
Random random = new Random();
Set<Integer> theIntSet = new HashSet<>();
for(int i = 0; i < 10;i++) {
theIntSet.add(Integer.valueOf(random.nextInt(100)));
}
theIntSet.forEach(ThatClass::thatIs);
}
public static class ThatClass {
public static void thatIs(int i) {
System.out.printf("That is %d%n", i);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.