Add a Node to the Front
easyQuestion 425An IntList keeps its nodes in a chain that starts at head. Inserting at the front is the cheapest thing a linked list does: no walking, just two pointer moves.
Requirements:
1. isEmpty() returns true when the list has no nodes.
2. addFirst(int value) creates a node, links it ahead of the current head, and moves head onto it.
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
true 10 -> 20 -> 30 -> null false 3
= newline. The output ends with a newline, so 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.