package CtCILibrary;

import java.util.ArrayList;

public class LinkedListNode {
	public LinkedListNode next;
	public LinkedListNode prev;
	public LinkedListNode last;
	public int data;
	public LinkedListNode(int d, LinkedListNode n, LinkedListNode p) {
		data = d;
		setNext(n);
		setPrevious(p);
	}
	
	public LinkedListNode() { }

	public void setNext(LinkedListNode n) {
		next = n;
		if (this == last) {
			last = n;
		}
		if (n != null && n.prev != this) {
			n.setPrevious(this);
		}
	}
	
	public void setPrevious(LinkedListNode p) {
		prev = p;
		if (p != null && p.next != this) {
			p.setNext(this);
		}
	}	
	
	public String printForward() {
		if (next != null) {
			return data + "->" + next.printForward();
		} else {
			return ((Integer) data).toString();
		}
	}
	
	public LinkedListNode clone() {
		LinkedListNode next2 = null;
		if (next != null) {
			next2 = next.clone();
		}
		LinkedListNode head2 = new LinkedListNode(data, next2, null);
		return head2;
	}

	public int[] toIntArray() {
		ArrayList<Integer> intArrayList = new ArrayList<Integer>();
		LinkedListNode node = this;
		while (node.next != null) {
			intArrayList.add(node.data);
			node = node.next;
		}
		int[] intArray = new int[intArrayList.size()];
		int i = 0;
		for (Integer n : intArrayList) {
			intArray[i] = n;
			i++;
		}
		return intArray;
	}
}

package CtCILibrary;

import java.util.ArrayList;

public class LinkedListNode {
	public LinkedListNode next;
	public LinkedListNode prev;
	public LinkedListNode last;
	public int data;
	public LinkedListNode(int d, LinkedListNode n, LinkedListNode p) {
		data = d;
		setNext(n);
		setPrevious(p);
	}
	
	public LinkedListNode() { }

	public void setNext(LinkedListNode n) {
		next = n;
		if (this == last) {
			last = n;
		}
		if (n != null && n.prev != this) {
			n.setPrevious(this);
		}
	}
	
	public void setPrevious(LinkedListNode p) {
		prev = p;
		if (p != null && p.next != this) {
			p.setNext(this);
		}
	}	
	
	public String printForward() {
		if (next != null) {
			return data + "->" + next.printForward();
		} else {
			return ((Integer) data).toString();
		}
	}
	
	public LinkedListNode clone() {
		LinkedListNode next2 = null;
		if (next != null) {
			next2 = next.clone();
		}
		LinkedListNode head2 = new LinkedListNode(data, next2, null);
		return head2;
	}

	public int[] toIntArray() {
		ArrayList<Integer> intArrayList = new ArrayList<Integer>();
		LinkedListNode node = this;
		while (node.next != null) {
			intArrayList.add(node.data);
			node = node.next;
		}
		int[] intArray = new int[intArrayList.size()];
		int i = 0;
		for (Integer n : intArrayList) {
			intArray[i] = n;
			i++;
		}
		return intArray;
	}

	public int length() {
		int length = 1;
		LinkedListNode node = this;
		while (node.next != null) {
			node = node.next;
			length++;
		}
		return length;
	}

}

Add length() method.