Created
March 28, 2023 20:40
-
-
Save pavly-gerges/d044e3a87c4de4d42b4de98e00bbd5bf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
class TestSuperCapture { | |
static class TestSuper {} | |
static class TestSub extends TestSuper {} | |
static class TestSub2 extends TestSub {} | |
static class TestSub3 extends TestSub2 {} | |
public static void main(String[] args) { | |
/* capture objects that there super-class is TestSub */ | |
ArrayList<? super TestSub> list = new ArrayList<>(); | |
list.add(new TestSub2()); | |
list.add(new TestSub3()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment