Skip to content

Instantly share code, notes, and snippets.

@Scrappers-glitch
Created March 28, 2023 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Scrappers-glitch/d044e3a87c4de4d42b4de98e00bbd5bf to your computer and use it in GitHub Desktop.
Save Scrappers-glitch/d044e3a87c4de4d42b4de98e00bbd5bf to your computer and use it in GitHub Desktop.
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