Lowest price ever! Learn Generative AI for 48% less!
Get my discount+ 6
Linked List remove.
I don't have much experience with Java and I am having trouble with removing first node of linked list in this code. I think line 22 has no effect. why is that? what can I do to fix that? Thanks in advance. https://code.sololearn.com/cFp5d0uc6Ubw/?ref=app
7 Answers
+ 15
Thank you for the invitation.
I agree with 「HAPPY TO HELP」
Return is the only option in your code.
If you do not want to return, then you have to modify the code like this:
https://code.sololearn.com/c598YVmqpa0Z/?ref=app
+ 12
It appears youre deleting locally. Java "pointers" can get tricky! They work one way, but doing the same thing may not work elsewhere.
I added remove 30 to test it out
https://code.sololearn.com/cCSmBjjGpziu/?ref=app
+ 12
Tanay
Thank you my friend for such a nice words.
I looked at your codes and really am thrilled with them 👍 Please, just keep it going - I'll keep my eyes on your work 👀 and enjoy in your codes 😊
+ 11
Youre welcome :)
As you have it, no not that I know of.
What I do is I have a seperate class for Node and declare a Node head and Node tail in the linked list class and that usually helps. You dont have to return anything; the list gets updated in the linked list class
+ 6
Thank you LukArToDo for reply.
It really helps me a lot to get to know java better and better. Your code always inspires me.
Thank you both 「HAPPY TO HELP」 &
LukArToDo.
+ 4
LukArToDo Hey, I have seen your lots of code of java and learned lot from it and I think you can help me out with this.
please take a look at this when you have some free time.
+ 4
thank you so much.....「HAPPY TO HELP」
just curious to know... is there any way I can do it without retuning list?