From 5ce337fa54373fd984fe00b42e06a8300e5249b0 Mon Sep 17 00:00:00 2001 From: asri71 Date: Tue, 5 Mar 2019 17:08:54 +0530 Subject: [PATCH] Code changes to adhere to code best practices --- src/main/java/com/types/Queue.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/types/Queue.java b/src/main/java/com/types/Queue.java index a247b348..11cfe78b 100644 --- a/src/main/java/com/types/Queue.java +++ b/src/main/java/com/types/Queue.java @@ -1,6 +1,8 @@ package src.main.java.com.types; +import java.util.NoSuchElementException; + /** * Interface to provide queue specific functionality to the implementing class * This interface only defines the functionality which the queue implementing classes require. @@ -10,7 +12,7 @@ package src.main.java.com.types; public interface Queue extends DataStructure { //Method to add element - public boolean offer(T t); + public boolean offer(T t) throws NullPointerException; //Method to remove element public T poll(); @@ -19,7 +21,7 @@ public interface Queue extends DataStructure { public T peek(); //Method to check element on head. This throws exception on runtime if the queue is empty - public T element(); + public T element() throws NoSuchElementException; }