In the put function,we are creating an object ‘pta’ for eg at address 85k and adding it to the linkedlist and for the get function we are creating another object ‘ptf’ but it will be made on another address na like 70k and yet how can we check on the linked list to find an object at 70k and yet get a result?
Hashtable Put and Get function
Hi @ap8730390,
Actually the find method defination is given in linkedList class which is this
public int find(T data) {
int index = 0;
for (Node temp = this.head; temp != null; temp = temp.next) {
if (temp.data.equals(data)) {
return index;
}
index++;
}
return -1;
}
This function uses equals method to compare and equal checks the content of the given two objects not the address hence even if the address is different we get the correct answer.
Hope this helps
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.