Question: * * MUST BE IN JAVA PLEASE * * Two integers, neighbors 1 and neighbors 2 , are read from input as the number of
MUST BE IN JAVA PLEASE
Two integers, neighbors and neighbors are read from input as the number of neighbors for two towns. headObj has the default value of Create a new node firstTown with integer neighbors and insert firstTown after headObj. Then, create a second node secondTown with integer neighbors and insert secondTown after firstTown.
Ex: If the input is then the output is:
import java.util.Scanner;
public class TownLinkedList
public static void mainString args
Scanner scnr new ScannerSystemin;
TownNode headObj;
TownNode firstTown;
TownNode secondTown;
TownNode currTown;
int neighbors;
int neighbors;
neighbors scnrnextInt;
neighbors scnrnextInt;
headObj new TownNode;
Your code goes here
currTown headObj;
while currTown null
currTown.printNodeData;
currTown currTown.getNext;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
