Connecting node in a linked list [closed]











up vote
-4
down vote

favorite












My question is : How can I connect the first node, last node and new node when I add item at the beginning or at any position?



Thanks



public class LinkedList2 implements StudentInterface {

public Node FirstNode;
public Node LastNode;
int length;

public LinkedList2(){
clear();
}

public final void clear(){
FirstNode=null;
LastNode=null;
length=0;
}

public boolean isEmpty(){
return length==0;
}

private class Node{
private Object Data;
private Node next;

private Node(Object Item){
Data=Item;
next=null;
}
private Node(Object Item , Node NextNode){
Data=Item;
next=NextNode;
}
}

public boolean Add(Object Item){
Node newNode= new Node(Item);

if(isEmpty()){
/* here aremy problems-------> FirstNode=newNode; */
/* here are my problems------->newNode.next=LastNode; */
}else{
/* here are my problems------->FirstNode.next=newNode; */
}
length++;
return true;
}









share|improve this question















closed as off-topic by 200_success, Heslacher, πάντα ῥεῖ, Ludisposed, Toby Speight Dec 6 at 8:53


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – 200_success, Heslacher, πάντα ῥεῖ, Ludisposed, Toby Speight

If this question can be reworded to fit the rules in the help center, please edit the question.













  • Welcome on Code Review. Unfortunately, we don't provide code, we review code you've written. Depending on your problem, another site of the StackExchange network can help you. Please see our help center for more information. The original question title, which states your concerns about the code, applies to too many questions on this site to be useful. The site standard is for the title to simply state the task accomplished by the code. Please see How to Ask for examples, and revise the title accordingly. Also, you should use {} button to auto format your code.
    – Calak
    Dec 6 at 6:45















up vote
-4
down vote

favorite












My question is : How can I connect the first node, last node and new node when I add item at the beginning or at any position?



Thanks



public class LinkedList2 implements StudentInterface {

public Node FirstNode;
public Node LastNode;
int length;

public LinkedList2(){
clear();
}

public final void clear(){
FirstNode=null;
LastNode=null;
length=0;
}

public boolean isEmpty(){
return length==0;
}

private class Node{
private Object Data;
private Node next;

private Node(Object Item){
Data=Item;
next=null;
}
private Node(Object Item , Node NextNode){
Data=Item;
next=NextNode;
}
}

public boolean Add(Object Item){
Node newNode= new Node(Item);

if(isEmpty()){
/* here aremy problems-------> FirstNode=newNode; */
/* here are my problems------->newNode.next=LastNode; */
}else{
/* here are my problems------->FirstNode.next=newNode; */
}
length++;
return true;
}









share|improve this question















closed as off-topic by 200_success, Heslacher, πάντα ῥεῖ, Ludisposed, Toby Speight Dec 6 at 8:53


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – 200_success, Heslacher, πάντα ῥεῖ, Ludisposed, Toby Speight

If this question can be reworded to fit the rules in the help center, please edit the question.













  • Welcome on Code Review. Unfortunately, we don't provide code, we review code you've written. Depending on your problem, another site of the StackExchange network can help you. Please see our help center for more information. The original question title, which states your concerns about the code, applies to too many questions on this site to be useful. The site standard is for the title to simply state the task accomplished by the code. Please see How to Ask for examples, and revise the title accordingly. Also, you should use {} button to auto format your code.
    – Calak
    Dec 6 at 6:45













up vote
-4
down vote

favorite









up vote
-4
down vote

favorite











My question is : How can I connect the first node, last node and new node when I add item at the beginning or at any position?



Thanks



public class LinkedList2 implements StudentInterface {

public Node FirstNode;
public Node LastNode;
int length;

public LinkedList2(){
clear();
}

public final void clear(){
FirstNode=null;
LastNode=null;
length=0;
}

public boolean isEmpty(){
return length==0;
}

private class Node{
private Object Data;
private Node next;

private Node(Object Item){
Data=Item;
next=null;
}
private Node(Object Item , Node NextNode){
Data=Item;
next=NextNode;
}
}

public boolean Add(Object Item){
Node newNode= new Node(Item);

if(isEmpty()){
/* here aremy problems-------> FirstNode=newNode; */
/* here are my problems------->newNode.next=LastNode; */
}else{
/* here are my problems------->FirstNode.next=newNode; */
}
length++;
return true;
}









share|improve this question















My question is : How can I connect the first node, last node and new node when I add item at the beginning or at any position?



Thanks



public class LinkedList2 implements StudentInterface {

public Node FirstNode;
public Node LastNode;
int length;

public LinkedList2(){
clear();
}

public final void clear(){
FirstNode=null;
LastNode=null;
length=0;
}

public boolean isEmpty(){
return length==0;
}

private class Node{
private Object Data;
private Node next;

private Node(Object Item){
Data=Item;
next=null;
}
private Node(Object Item , Node NextNode){
Data=Item;
next=NextNode;
}
}

public boolean Add(Object Item){
Node newNode= new Node(Item);

if(isEmpty()){
/* here aremy problems-------> FirstNode=newNode; */
/* here are my problems------->newNode.next=LastNode; */
}else{
/* here are my problems------->FirstNode.next=newNode; */
}
length++;
return true;
}






java linked-list






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 6 at 6:41









Calak

2,092318




2,092318










asked Dec 6 at 5:14









Mohammad W. Al-Shatarat

1




1




closed as off-topic by 200_success, Heslacher, πάντα ῥεῖ, Ludisposed, Toby Speight Dec 6 at 8:53


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – 200_success, Heslacher, πάντα ῥεῖ, Ludisposed, Toby Speight

If this question can be reworded to fit the rules in the help center, please edit the question.




closed as off-topic by 200_success, Heslacher, πάντα ῥεῖ, Ludisposed, Toby Speight Dec 6 at 8:53


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – 200_success, Heslacher, πάντα ῥεῖ, Ludisposed, Toby Speight

If this question can be reworded to fit the rules in the help center, please edit the question.












  • Welcome on Code Review. Unfortunately, we don't provide code, we review code you've written. Depending on your problem, another site of the StackExchange network can help you. Please see our help center for more information. The original question title, which states your concerns about the code, applies to too many questions on this site to be useful. The site standard is for the title to simply state the task accomplished by the code. Please see How to Ask for examples, and revise the title accordingly. Also, you should use {} button to auto format your code.
    – Calak
    Dec 6 at 6:45


















  • Welcome on Code Review. Unfortunately, we don't provide code, we review code you've written. Depending on your problem, another site of the StackExchange network can help you. Please see our help center for more information. The original question title, which states your concerns about the code, applies to too many questions on this site to be useful. The site standard is for the title to simply state the task accomplished by the code. Please see How to Ask for examples, and revise the title accordingly. Also, you should use {} button to auto format your code.
    – Calak
    Dec 6 at 6:45
















Welcome on Code Review. Unfortunately, we don't provide code, we review code you've written. Depending on your problem, another site of the StackExchange network can help you. Please see our help center for more information. The original question title, which states your concerns about the code, applies to too many questions on this site to be useful. The site standard is for the title to simply state the task accomplished by the code. Please see How to Ask for examples, and revise the title accordingly. Also, you should use {} button to auto format your code.
– Calak
Dec 6 at 6:45




Welcome on Code Review. Unfortunately, we don't provide code, we review code you've written. Depending on your problem, another site of the StackExchange network can help you. Please see our help center for more information. The original question title, which states your concerns about the code, applies to too many questions on this site to be useful. The site standard is for the title to simply state the task accomplished by the code. Please see How to Ask for examples, and revise the title accordingly. Also, you should use {} button to auto format your code.
– Calak
Dec 6 at 6:45















active

oldest

votes






















active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

Список кардиналов, возведённых папой римским Каликстом III

Deduzione

Mysql.sock missing - “Can't connect to local MySQL server through socket”