public void add(int d){ listNode l = new listNode (d, null); l.next = first; first= l; } public list Sum2List (list l1, list l2){ //variables int sum; list l = new list (); listNode p1= l1.first; listNode p2= l2.first; while (p1!=null){ sum= p1.data + p2.data; l.add(sum); p1= p1.next; p2= p2.next; } return l; }
but I have a problem in my first listNode where it ll be pointing to null, thus in the sum2List method the program checks the while condition into false and doesn't go through the loop,,
may u help me correct my code plz,,
thank u in advance;;
I appreciate giving me some of ur time ,,