Answered You can hire a professional tutor to get the answer.

QUESTION

How can I get the first element from a linked list?

How can I get the first element from a linked list?

For example, if I am working on a number guessing game with linked list, and there is a list called priorGuess, which stores all the guesses that is given. PriorGuess has a order such that the first given guess is in the first node, and the last given guess is in the last node.

However, I don't want the last one, I want the first one.

I know for getting the last node, you need while(priorGuess.getLink()!=null){priorGuess = priorGuess.getLink();} or something like that.

But I really don't have any clue about how to get the first node.

Can someone help me on that one please?

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question