← Back to Data Structures & Algorithms
Question 427
Remove the First Node
Remove the First Node
Unlinking the head node is the mirror image ofaddFirst(): read the value out, then let head skip over the node being dropped. Requirements: 1.removeFirst()removes the first node and returns the value it held. 2. On an empty list it returns -1 and prints nothing. The Node class is provided - do not rename it and do not add public to it, because a Java source file may contain only one public class. Do NOT write a main method.
Expected Output:
10 20 -> 30 -> null 2
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
Data Structures & AlgorithmsLinked Lists
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (sysout, psvm, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.