toString why you be so stubborn
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package linkedlist;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class EmptyListException extends RuntimeException{
|
||||
public EmptyListException() {}
|
||||
public EmptyListException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
@@ -103,10 +103,13 @@ public class MyList<E> {
|
||||
}
|
||||
|
||||
public E removeAt(int index) {
|
||||
if (size() == 0) {
|
||||
throw new EmptyListException("The list is empty.");
|
||||
}
|
||||
if (index < 0 || index >= size())
|
||||
throw new IndexOutOfBoundsException();
|
||||
if (size() == 0)
|
||||
throw new RuntimeException("Empty List");
|
||||
throw new EmptyListException("Empty List");
|
||||
E removedE = null;
|
||||
if (index == 0) {
|
||||
// remove the front
|
||||
|
Reference in New Issue
Block a user