Guest User

Untitled

a guest
Dec 7th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. @Override
  2. public T[] toArray(){
  3. int indice = 0;
  4. T[] result = (T[]) new Object[size()];
  5. toArrayRecursive(result, this, indice);
  6. return result;
  7. }
  8.  
  9. private void toArrayRecursive(T[] result, RecursiveSingleLinkedListImpl<T> node, int indice){
  10. if(!node.isEmpty()){
  11. result[indice] = node.data;
  12. indice ++;
  13. toArrayRecursive(result, node.next, indice);
  14. }
  15. }
Add Comment
Please, Sign In to add comment