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???

20th Jan 2020, 7:14 PM
Wasiq Abdullah
6 Answers
+ 1
here in Java, variables ptr and first stores reference (address) to object of type Node, but it is not called pointer.
21st Jan 2020, 6:53 AM
zemiak
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 }
20th Jan 2020, 9:38 PM
zemiak
0
zemiak here why u put first=ptr. ....
20th Jan 2020, 9:54 PM
Wasiq Abdullah
0
you need to store head object to variable first, not to ptr
20th Jan 2020, 10:34 PM
zemiak
0
here please clarify... i am really confused what is pointer and what is variable..can variable store address???
21st Jan 2020, 5:05 AM
Wasiq Abdullah
0
means (first) variable will only stores address oif Object
22nd Jan 2020, 6:50 AM
Wasiq Abdullah