Skip to content

Instantly share code, notes, and snippets.

@arinto
Created April 7, 2014 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arinto/10023804 to your computer and use it in GitHub Desktop.
Save arinto/10023804 to your computer and use it in GitHub Desktop.
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