Skip to content

Instantly share code, notes, and snippets.

@ashishkumarsinghh
Created July 18, 2018 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashishkumarsinghh/cfb9f27b9122c4de9167085fd5ed8415 to your computer and use it in GitHub Desktop.
Save ashishkumarsinghh/cfb9f27b9122c4de9167085fd5ed8415 to your computer and use it in GitHub Desktop.
package SelfPractice;
public class SLLNode{
int data;
SLLNode next;
SLLNode(int data){
this.data = data;
this.next = null;
}
SLLNode(){
this.data = -1;
this.next = null;
}
public SLLNode addAtEnd(SLLNode node){
if(this.data != -1){
SLLNode curr = this;
while(curr.next != null){
curr = curr.next;
}
curr.next = node;
return this;
}
else{
this.data = node.data;
return this;
}
}
public void printLL(){
SLLNode node = this;
while(node != null){
System.out.print(node.data +"-->");
node = node.next;
}
System.out.print("NULL");
System.out.println();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment