1.链表类

class ListNode{
	int val;
	ListNode nextNode;
	ListNode(int val){
		this.val=val;
		this.nextNode=null;
	}
}

2.生成链表

//生成int类型链表的方法
    private static ListNode intlistNode(int[] in){
		ListNode head=null,next=null,tmp;
		for (int i : in) {
			tmp=new ListNode(i);
			if(head==null){
				head=tmp;
				next=tmp;
			}else {
				next.nextNode=tmp;
				next=tmp;
			}
		}
		return head;
	}

3.实例化链表对象

//实例化一个int类型的链表
    int[] a={1,2,3,4,5};
    ListNode l1;
    l1=intlistNode(a);//调用上面的方法