For example, lets say you have two classes:
public class TestA {}
public class TestB extends TestA{}
I have a method that returns a L
class MyClass {
String field;
MyClass(String field) {
this.field = field;
}
}
@Test
public void testTypeCast() {
List
This test shows how to cast List
to List
. But you need to take an attention to that objectList
must contain instances of the same type as MyClass
. And this example can be considered when List
is used. For this purpose get field Class
in constructor and use it instead of MyClass.class
.