Why can't I push onto stack? Java 6 generics -
i have no idea why i'm unable simple push generic type of object onto stack. i've decided need figuring out. have: private void preordertrav(bstnode<k> node) { if(node != null){ mystack.push(node); //null pointer exception while(!mystack.isempty()){ mystack.pop(); node = node.getleft(); mystack.push(node.getright()); mystack.push(node.getleft()); } } } this being called constructor: public bstsortedlistiterator(bstnode<k> root) { preordertrav(root); } anyone have ideas? error, way: exception in thread "main" java.lang.nullpointerexception @ bstsortedlistiterator.preordertrav(bstsortedlistiterator.java:33) @ bstsortedlistiterator.preordertrav(bstsortedlistiterator.java:31) @ bstsortedlistiterator.<init>(bstsortedlistiterator.java:43) @ bstsortedlist.iterator(bstsortedlist.ja...