You are not changing pointer for head
for initial case and head
is always null
.
if(cur==null){
cur = nn;
}
should be
if(head==null){
head = nn;
}
More Related Contents:
- Exception in thread “main” java.util.NoSuchElementException: No line found – Using scanner input [duplicate]
- How to put HashMap into different elements with same key
- ListIterator Strange Adding to ArrayList
- Range of linked lists [closed]
- When to use LinkedList over ArrayList in Java?
- How to detect a loop in a linked list?
- Reversing a linked list in Java, recursively
- How do I create a Linked List Data Structure in Java? [closed]
- Where can I see the source code of the Sun JDK?
- What exactly is bucket in hashmap?
- Why is ArrayDeque better than LinkedList
- ArrayList Vs LinkedList
- ArrayList vs LinkedList from memory allocation perspective
- Java how to sort a Linked List?
- Creating a LinkedList class from scratch
- Is LinkedList thread-safe when I’m accessing it with offer and poll exclusively?
- Adding items to end of linked list
- Java IO implementation of unix/linux “tail -f”
- Preferred way of loading resources in Java
- Exception in thread “main” java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver
- How cancel the execution of a SwingWorker?
- Launching activities within a tab in Android
- Generics : List
- Get generated id after insert
- Using maven to output the version number to a text file
- getLocationOnScreen() vs getLocationInWindow()
- IntelliJ Build Error Context Mismatch
- Attaching additional javadoc in Intellij IDEA
- How to update xml files in java
- How do I use StringUtils in Java?