0
Hello Guys help me..LinkedList code
https://code.sololearn.com/crP73lVS4tH6/?ref=app.. here in line no 31 we used first=first.next ....due to which first becomes null and we can remove 1st value...is it p0ossible that in remove () function i do just like ptr=first; ptr=ptr.next; due to which i can make ptr as null and delete first value.... is this poasible or not...if it s not possible then why???
6 Réponses
+ 1
here in Java, variables ptr and first stores reference (address) to object of type Node, but it is not called pointer.
0
you can do this, but it is redundant
public void removeFront2() {
ptr=first; //first=x; ptr=x
ptr=ptr.next; //first=x; ptr=y
first=ptr; //first=y; ptr=y
}
0
zemiak here why u put first=ptr. ....
0
you need to store head object to variable first, not to ptr
0
here please clarify... i am really confused what is pointer and what is variable..can variable store address???
0
means (first) variable will only stores address oif Object