Question: You will be working with and making a Generic class. (1) Complete the Generic Node class per the following specifications: Private class attributes generic element

You will be working with and making a Generic class.

(1) Complete the Generic Node class per the following specifications: Private class attributes generic element class reference for a next node, Public methods: Constructors: empty and non-empty parameter list - (1 pt each) setElement() (1 pt) setNext() (1 pt) getElement() (1 pt) getNext() (1 pt)

(2) In the Main class, complete all of the TODOs The output should be: Node element = Hello Dave, next node = null Node element = 10.55, next node = null Node element = 5, next node = null Node element = Java, next node = null Node element = 20, next node = Node element = Ariana, next node = null

LABACTIVITY 3.5.1: Lab 1

import java.util.ArrayList; import java.util.Scanner;

public class Main {

static Scanner scnr = new Scanner(System.in); public static void main(String[] args) {

TODO: Instantiate a String Node object storing the value "Hello Dave"

// TODO: In a print statement, call the toString method of the Node class // for the Node you just instantiated.

// 2. TODO: Instantiate a Double Node object storing the value 10.55

// TODO: In a print statement, call the toString method of the Node class // for the Second Node you just instantiated. // 3. TODO: Instantiate an ArrayList of Node objects

// TODO: Assign the first cell of the ArrayList an new Integer Node with the value of 5

// TODO: Assign the second cell of the ArrayList a new String Node with the value of "Java"

// TODO: Print the Nodes in the ArrayList

// 4. TODO: Instantiate an Integer Node object storing the value 20

// TODO: Instantiate a new String Node with the value "Ariana" and set it as the integer Nodes next node // this makes the integer node point to the String node

// TODO: Print the Integer Node from TODO 4 } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!