Add new test classes

This commit is contained in:
Till Schnell 2021-04-13 11:57:10 +02:00
parent e5f03369cc
commit 5a151a965c
3 changed files with 33 additions and 3 deletions

View File

@ -0,0 +1,23 @@
import java.util.List;
import java.lang.String;
public final class TestClassWildcardsParamType<T1, T2> {
public final T1 first;
public final T2 second;
public TestClassWildcardsParamType(T1 first, T2 second) {
this.first = first;
this.second = second;
}
public static <T1, T2> TestClassWildcardsParamType<T1, T2> of(T1 first, T2 second) {
return new TestClassWildcardsParamType<T1, T2>(first, second);
}
public static void main(String[] agrs) {
TestClassWildcardsParamType<Class<?>, String> pair = TestClassWildcardsParamType.of(List.class, "hello");
//Outout of compiler
//TestClassWildcardsParamType<? extends Class<?>, String> pair = TestClassWildcardsParamType.of(List.class, "hello");
}
}

View File

@ -5,9 +5,6 @@ import java.lang.Object;
class TestClassWildcardsSingle
{
public TestClassWildcards () {
}
/**
* Non working method in normal Java
* @param input

View File

@ -0,0 +1,10 @@
import java.util.List;
class TestClassWildcardsLib
{
public <T> List<T> merge (List<T> l1, List<T> l2) {
l2.forEach(s -> {if(!l1.contains(s)) l1.add(s);});
return l2;
}
}