From 59b45b5f87f16bddad1d8220efee29e6d09ce948 Mon Sep 17 00:00:00 2001 From: Till Schnell Date: Sat, 27 Mar 2021 18:04:28 +0100 Subject: [PATCH] Add test method --- .../inferWildcards/TestClassWildcards.java | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/src/test/resources/inferWildcards/TestClassWildcards.java b/src/test/resources/inferWildcards/TestClassWildcards.java index cb597cf6..61f16c9c 100644 --- a/src/test/resources/inferWildcards/TestClassWildcards.java +++ b/src/test/resources/inferWildcards/TestClassWildcards.java @@ -1,20 +1,38 @@ import java.util.ArrayList; -class TestClassWildcards { +class TestClassWildcards +{ - private List field1; + private List field1; private int counter; - public TestClassWildcards(){ - field1 = new ArrayList<>(); + public TestClassWildcards () { + field1 = new ArrayList<>(); counter = 0; - } + } - public List test(List param1){ - List localVar = field1; - field1 = param; + /** + * Working method for Java + * @param param1 + * @return + */ + public List test (List param1) { + List localVar = field1; + field1 = param; counter++; - return localVar; - } + return localVar; + } + /** + * Non working method in normal Java + * @param input + * @return + */ + public List test2 (List input) { + List listOfObjects = input; + Object test = listOfObjects.get(0); + String string = "Test"; + input.add(string); + return listOfObjects; + } } \ No newline at end of file