class Superclass<T> { private T element; public Superclass(T element) { this.element = element; } public T getEle() { return this.element; } } class Subclass<T, V> extends Superclass<T> { private V value; public Subclass(T element, V value) { super(element); this.value = value; } public V getValue() { return this.value; } } public class Hierarchy { public static void main(String[] args) { System.out.println(" ABC"); Subclass<String, Integer> h1 = new Subclass<>("abc", 123); System.out.println(h1.getEle()); System.out.println(h1.getValue()); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter