hi all,
I am new to java, i tried the following way of finding the indexes of duplicae elements. Please help me with much efficient way with less iterations with out using collection classes
public class Sample {
public static void main(String[] args) {
String[] strs= {"AA","GG","AA","AA","BOB"};
ArrayList equalsList=new ArrayList();
for(int i=0;i<=4;i++)
{
for(int j=0;j<=4;j++)
{
if(strs!=null && !"".equals(strs[i])&& strs[i]==strs[j] && i!=j)
{
System.err.println(i+1+ " ---"+ (j+1));
equalsList.add(i+1);
break;
}
}
}
System.err.println(equalsList);
}
Thanks...