Question
PLEASE HELP IN JAVA: Alter your program to make the code as efficient and modular as possible. Use ONE method to construct your first list,
PLEASE HELP IN JAVA:
Alter your program to make the code as efficient and modular as possible. Use ONE method to construct your first list, and ONE method to add a node to a list. YOU DO NOT NEED TWO METHODS (one for the odd list and one for the even list!!!)
Also, prepend is the easiest way to add to a list if you are not told otherwise.
newNode.next = head;
head = newNode;
This is an exercise in using nodes, so no extra credit for using linkedList class, lists etc.
Rubric:
* One method to get the integers and create first list
* one method (used three times) to add a node to a list
Program:
public static void main(String[] args) { //create a list called "list1" that conatains integers Scanner keyboard = new Scanner(System.in); List
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started