What is the diffrence of between this code:
{
...
int counter = 0;
for (String item : Names)
{
int i = item.indexOf("a");
counter = i;
}
return counter;
...
}
and this :
{
...
int counter = 0;
for (String item : Names)
{
if(item == "a")
return counter;
else
counter++;
}
return null ;
...
}
In facti, How to work the indexOf method in java? Thanks.