Created
September 22, 2015 22:06
-
-
Save MLLeKander/18e5387bfb3cad1e5bc0 to your computer and use it in GitHub Desktop.
Yaaay java...
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.lang.reflect.Array; | |
class Sup<T> { | |
T[] arr; | |
@SuppressWarnings("unchecked") | |
public Sup(int r) { | |
arr = (T[])new Object[r]; | |
//arr = (T[])Array.newInstance(Object.class, r); | |
} | |
public void printSup() { | |
System.out.println("Printing from sup."); | |
for (Object i : arr) { | |
System.out.print(i+" "); | |
} | |
System.out.println(); | |
} | |
} | |
class Sub extends Sup<String> { | |
public Sub(int r) { | |
super(r); | |
} | |
public void printSub() { | |
System.out.println("Printing from sub."); | |
for (Object i : arr) { | |
System.out.print(i+" "); | |
} | |
System.out.println(); | |
} | |
public static void main(String[] args) { | |
Sub s = new Sub(4); | |
s.printSup(); | |
s.printSub(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment