Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public T[] toArray(){
- int indice = 0;
- T[] result = (T[]) new Object[size()];
- toArrayRecursive(result, this, indice);
- return result;
- }
- private void toArrayRecursive(T[] result, RecursiveSingleLinkedListImpl<T> node, int indice){
- if(!node.isEmpty()){
- result[indice] = node.data;
- indice ++;
- toArrayRecursive(result, node.next, indice);
- }
- }
Add Comment
Please, Sign In to add comment