You are on page 1of 2

package PrelimExam;

import java.util.NoSuchElementException;

public abstract class MySinglyLinkedList<E> implements MyExtendedList<E> {


private Node<E> newList;
private int size;
public Node head = null;
public Node tail = null;

public void setNext(){


Node node = head;
if (head == null) {
System.out.println("List is Empty");
return;
}
while (node != null) {
System.out.println(node.getData + " ");
node = node.getNext;
}
System.out.println();

}
public void getData(int data){
Node newNode = new Node(data);

if (head == null) {

head = newNode;
tail = newNode;
} else {

tail.getNext = newNode;

tail = newNode;
}

public static void main(String[] args) {


System.out.println("Singly Linked List");
MySinglyLinkedList add = new MySinglyLinkedList() {
@Override
public int getSize() {
return 0;
}

@Override
public void insert(Object data) throws ListOverflowException {

@Override
public Object getElement(Object data) throws NoSuchElementException {
return null;
}

@Override

This study source was downloaded by 100000851302356 from CourseHero.com on 08-30-2022 04:32:18 GMT -05:00

https://www.coursehero.com/file/110346809/MySinglyLinkedListjava/
public boolean delete(Object data) {
return false;
}

@Override
public boolean search(Object data) {
return false;
}

@Override
public void insert() {

@Override
public void insert(int index, Object data) throws ListOverflowException
{

@Override
public Object getElement(int index) throws NoSuchElementException {
return null;
}

@Override
public boolean delete(int index) {
return false;
}

@Override
public int search(Object data, int startIndex) {
return 0;
}
};
add.getData(1);
add.getData(2);
add.getData(3);
add.getData(4);

add.setNext();
}

}
class Node<E> {
int getData;
Node<E> getNext;

public Node(int data) {


this.getData = data;
this.getNext = null;
}
}

This study source was downloaded by 100000851302356 from CourseHero.com on 08-30-2022 04:32:18 GMT -05:00

https://www.coursehero.com/file/110346809/MySinglyLinkedListjava/
Powered by TCPDF (www.tcpdf.org)

You might also like