• #### Ruchika

List created by add operation as said in the above post is 3 5 4 7 , I think the list will be 3 5 7 4 and not 3 5 4 7. Please correct me if my understanding is wrong

• #### Davide

import java.util.Scanner;

``````Node head;
Node tail;

/*
* Adds Node to end of list with given `num` as data
``````
• #### Sarick Shah

``````public void add(int num){
tail.next = new Node(num);
tail = tail.next;

}

/*
* Returns value of node at given index
``````
• #### Sarick Shah

what am i supposed to return?

• #### Sarick Shah

import java.util.Scanner;

``````Node head;
Node tail;
private Node temp = null;

/*
* Adds Node to end of list with given `num` as data
``````
• #### Sarick Shah

this is telling me that my return value needs to be an integer, I'm lost

• #### Learneroo

@sarah, you can link to long pieces of code so you don't need to paste them here. The method `get` needs to return an integer (the value or data of a node). See if the new hint helps (or the new cheat option if you need it.)

• #### Sarick Shah

thanks, i realize what i was doing wrong.

• #### thales

Do i understand it correct if i say that head and tails arent nodes themselves?

• #### Learneroo

No, the first node in the list is the head and the last node is the tail. (If there's just one node, it's both the head and tail.)

• #### thales

When i state tail is head , can i consider them as one node with 2 names (startingpoint), or are they two different nodes with the same name. In case two i dont understand the line:

• #### thales

Node tail;

So i have two 'dummy' nodes. But what is the data en what is the pointer of head.

if head==0 -------------> what does this mean, what is null, the pointer? Then what is the data?

• #### thales

Nevermind, i understand it now. Its cause the default points to null.

Also i understand why i can say tail.next and it does the same for the head. This cause its a reference variable. So i guess i figured it out :-)

• #### catypus

Why is it supposed to be
and not

THis is driving me nuts! I drew this out on paper TWICE and while I understand the concept... I cant code it!

• #### Learneroo

Which part are you referring to? When there's only one item in the list, that item is both the head and the tail. This a correct solution.

• #### oorja

is that python 2.6
I am using python 3.5 working ok on my ide but here it is failing on