OnJava8-Examples/streams/Looping.java

21 lines
470 B
Java
Raw Normal View History

// streams/Looping.java
2015-12-15 11:47:04 -08:00
// (c)2016 MindView LLC: see Copyright.txt
2015-11-15 15:51:35 -08:00
// We make no guarantees that this code is fit for any purpose.
2016-09-23 13:23:35 -06:00
// Visit http://OnJava8.com for more book information.
import static onjava.Repeat.*;
public class Looping {
static void hi() { System.out.println("Hi!"); }
public static void main(String[] args) {
repeat(3, () -> System.out.println("Looping!"));
repeat(2, Looping::hi);
}
}
/* Output:
Looping!
Looping!
Looping!
Hi!
Hi!
*/