Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.stream.Collectors;
- import java.util.stream.Stream;
- public class Test {
- @FunctionalInterface
- interface Varargs { String meth(int i, String... strings); }
- @FunctionalInterface
- interface NoVarargs { String meth(int i); }
- @org.testng.annotations.Test
- public void test() {
- Varargs f1 = this::myMethod;
- System.out.println(f1.meth(2, "hello", "world"));
- NoVarargs f2 = this::myMethod;
- System.out.println(f2.meth(2));
- }
- String myMethod(int i, String... strings) {
- return i + ":" + Stream.of(strings).collect(Collectors.joining(":"));
- }
- // String myMethod(Integer i) { return i + ":NO_STRINGS: Integer"; }
- // String myMethod(Long i) { return i + ":NO_STRINGS: Long"; }
- // String myMethod(byte i) { return i + ":NO_STRINGS: byte"; }
- // String myMethod(Byte i) { return i + ":NO_STRINGS: Byte"; }
- // String myMethod(Float i) { return i + ":NO_STRINGS: Float"; }
- // String myMethod(float i) { return i + ":NO_STRINGS: float"; }
- // String myMethod(Double i) { return i + ":NO_STRINGS: Double"; }
- // String myMethod(double i) { return i + ":NO_STRINGS: double"; }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement