For example if i am working on a number guessing game with


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.

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: For example if i am working on a number guessing game with
Reference No:- TGS02919423

Now Priced at $10 (50% Discount)

Recommended (91%)

Rated (4.3/5)