Update LinkedList.java

Add code to detect a cycle