Skip to content

Instantly share code, notes, and snippets.

@theomega
Created January 11, 2016 08:28
Show Gist options
  • Save theomega/902ab54572e05bca46f9 to your computer and use it in GitHub Desktop.
Save theomega/902ab54572e05bca46f9 to your computer and use it in GitHub Desktop.
package com.company;
public class Main {
public static void main(String[] args) {
executeNTimes(10, ((currentIndex, maxIndex, wisdom) -> {
System.out.println("Executed run "+currentIndex+" of "+maxIndex+" Wisdom: "+wisdom);
}));
}
public static void executeNTimes(int n, CallbackInterface f) {
for(int i=0; i<n; i++) {
f.run(i, n, "current daily wisdom");
}
}
private interface CallbackInterface {
void run(int currentIndex, int maxIndex, String dailyWisdom);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment