Course Solutions Uncategorized (Solved) : Java Implement Following Methods Indicated Within Code Stacklistjava Public Class Node Int Q29097766 . . . .

(Solved) : Java Implement Following Methods Indicated Within Code Stacklistjava Public Class Node Int Q29097766 . . . .

 

In java implement the following methods as indicated within thecode of stacklist.java

public class Node{

int data;

Node next;

public Node(int data){

this.data = data;

next = null;

}

}

import java.util.Scanner;

public class LinkedListBasic {

Node head;

Node tail;

// inserts data to the end of the list only using the headpointer

public void append(int data){

if(head == null){

Node newNode = new Node(data);

head = newNode;

} else {

Node newNode = new Node(data);

Node currentNode = head;

while(currentNode.next != null){

currentNode = currentNode.next;

}

currentNode.next = newNode;

}

}

// inserts data to the beginning of the list

public void prepend(int data){

if(head == null){

Node newNode = new Node(data);

head = newNode;

return;

}

Node newNode = new Node(data);

newNode.next = head;

head = newNode;

}

// insert a new data after the given

OR

PayPal Gateway not configured

OR

PayPal Gateway not configured

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post