Data structure method in java [on hold]











up vote
-1
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? Assume that there is a interface called StudentInterface has three methods Add ,isEmpty, and print....i dont have the full code right now i have only the class who implements the Interface..if someone needed the full code i would add it.



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









New contributor




Mohammad W. Al-Shatarat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as off-topic by Vogel612 yesterday


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." – Vogel612

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













  • Welcome to Code Review! I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
    – Vogel612
    yesterday















up vote
-1
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? Assume that there is a interface called StudentInterface has three methods Add ,isEmpty, and print....i dont have the full code right now i have only the class who implements the Interface..if someone needed the full code i would add it.



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









New contributor




Mohammad W. Al-Shatarat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as off-topic by Vogel612 yesterday


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." – Vogel612

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













  • Welcome to Code Review! I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
    – Vogel612
    yesterday













up vote
-1
down vote

favorite









up vote
-1
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? Assume that there is a interface called StudentInterface has three methods Add ,isEmpty, and print....i dont have the full code right now i have only the class who implements the Interface..if someone needed the full code i would add it.



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









New contributor




Mohammad W. Al-Shatarat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











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? Assume that there is a interface called StudentInterface has three methods Add ,isEmpty, and print....i dont have the full code right now i have only the class who implements the Interface..if someone needed the full code i would add it.



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









New contributor




Mohammad W. Al-Shatarat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Mohammad W. Al-Shatarat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited yesterday









Vogel612

21.3k346128




21.3k346128






New contributor




Mohammad W. Al-Shatarat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked yesterday









Mohammad W. Al-Shatarat

1




1




New contributor




Mohammad W. Al-Shatarat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Mohammad W. Al-Shatarat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Mohammad W. Al-Shatarat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




put on hold as off-topic by Vogel612 yesterday


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." – Vogel612

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




put on hold as off-topic by Vogel612 yesterday


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." – Vogel612

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












  • Welcome to Code Review! I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
    – Vogel612
    yesterday


















  • Welcome to Code Review! I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
    – Vogel612
    yesterday
















Welcome to Code Review! I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
– Vogel612
yesterday




Welcome to Code Review! I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
– Vogel612
yesterday















active

oldest

votes






















active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

Quarter-circle Tiles

build a pushdown automaton that recognizes the reverse language of a given pushdown automaton?

Mont Emei