I want to return to result variable but eclipse marks that return result; part and says Create local variable 'result'.
The method i wrote:
public E getFromResults(int o)
{
Node tempNode = head;
for(int i=1; i<= size; i++)
{
if(i==o)
{
E result = (E) tempNode.getElement();
break;
}
tempNode=tempNode.getNext();
}
return result;
}
Okay i did it as shown below so it is working now thank you everone who answered for their help:
public E getFromResults(int o)
{
Node tempNode = head;
for(int i=1; i<= size; i++)
{
if(i==o)
break;
tempNode=tempNode.getNext();
}
E result = (E) tempNode.getElement();
return result;
}