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;
}
java linked-list
New contributor
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.
add a comment |
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;
}
java linked-list
New contributor
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
add a comment |
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;
}
java linked-list
New contributor
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
java linked-list
New contributor
New contributor
edited yesterday
Vogel612♦
21.3k346128
21.3k346128
New contributor
asked yesterday
Mohammad W. Al-Shatarat
1
1
New contributor
New contributor
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
add a comment |
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
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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