CRX: Doubt in loop

i think this can be a another way to go

for(int i=0; i<idx; i++)
temp=temp.next;

return temp.data;

please correct me if i am wrong;

@dheerajmishra992 yes u can start your loop from 0 and go to n-1 ,or start from 1 and go to n .