Generic Hacks
Generic Hacks
import java.util.LinkedList;
public class LL <T> {
public LinkedList<T> classes = new LinkedList<T>();
public Stack<T> stacks = new Stack<>();
public LL(T[] classes) {
makeList(classes);
}
public LinkedList<T> makeList(T[] classes) {
for (T data : classes) {
this.classes.add(data);
}
return this.classes;
}
public LinkedList<T> getClasses() {
return this.classes;
}
public void makeStack(LinkedList<T> classes) {
//System.out.println(classes.remove());
stacks.push(classes.remove());
stacks.push(classes.remove());
System.out.println("Stack: " + stacks);
}
public static void main(String[] args) {
String[] myClass = new String[]{"CSA", "CSP"};
LL<String> classReview = new LL<>(myClass);
System.out.println(classReview.getClasses());
LinkedList<String> classLL = classReview.getClasses();
classReview.makeStack(classLL);
}
}
LL.main(null)
import java.util.LinkedList;
public class LL {
public LinkedList<String> classes = new LinkedList<String>();
public Stack<String> classesStack = new Stack<>();
public LL() {
makeList();
}
public LinkedList<String> makeList() {
classes.add("CSA");
classes.add("CSP");
classes.add("Stats");
classes.add("APUSH");
classes.add("APEL");
return classes;
}
public LinkedList<String> getClasses() {
return this.classes;
}
public static void main(String[] args) {
LL classReview = new LL();
System.out.println(classReview.getClasses());
}
}
LL.main(null)