Preview:
int getAt(int idx) throws Exception {
		  
		  if(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.data;
		  
		}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter