mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-14 01:16:07 +08:00
Merge pull request #772 from abhijay94/master
Fix #771(position=size causes NullPointerException)
This commit is contained in:
@ -68,7 +68,7 @@ public class SinglyLinkedList {
|
|||||||
* This method deletes an element at Nth position
|
* This method deletes an element at Nth position
|
||||||
*/
|
*/
|
||||||
public void deleteNth(int position) {
|
public void deleteNth(int position) {
|
||||||
if (position < 0 || position > getSize()) {
|
if (position < 0 || position >= getSize()) {
|
||||||
throw new RuntimeException("position less than zero or position more than the count of list");
|
throw new RuntimeException("position less than zero or position more than the count of list");
|
||||||
} else if (position == 0)
|
} else if (position == 0)
|
||||||
deleteHead();
|
deleteHead();
|
||||||
|
Reference in New Issue
Block a user