private Node getNodeAt(int idx) throws Exception { if(this.size == 0){ throw new Exception("LinkedList is empty"); } if(idx < 0 || idx >= this.size){ throw new Exception("Invalid Index"); } Node temp = this.head; for(int i = 1; i <= idx; i++){ temp = temp.next; } return temp; }