Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

LO1 Summarize the organizations strategic planning process.

Answered: 1 week ago