
解题思路:
 直接往数组中加入数据,然后通过Java提供的工具类(coollections) 直接进行数组的反转。
  
代码实现:
import java.util.*;
/**
*    //ListNode 的数据结构
*
*    public class ListNode {
*        int val;
*        ListNode next = null;
*
*        ListNode(int val) {
*            this.val = val;
*        }
*    }
*
*/
public class Solution {
    public ArrayList<Integer> printListFromTailToHead(ListNode listNode) {
        ArrayList<Integer> arr = new ArrayList<Integer>();
        while(listNode!=null){
            arr.add(listNode.val);
            listNode = listNode.next;
        }
        Collections.reverse(arr);
        return arr;
    }
} 
 
                


















