Created
April 7, 2014 16:39
-
-
Save arinto/10023804 to your computer and use it in GitHub Desktop.
Static method reference example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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