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 

301936.1542274

LABACTIVITY

3.5.1: Lab 1

Current file:

Main.java

arrow_drop_downLoad default template...

import java.util.ArrayList;

import java.util.Scanner;

public class Main {

static Scanner scnr = new Scanner(System.in);

public static void main(String[] args) {

// 1. 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

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!