Ad
  • Custom User Avatar

    i have to find an integer which appears an odd number of times in an array. what am i doing wrong.help!

    public class FindOdd
    {
    public static int findIt(int[] a)
    {
    int odd,b;
    for(int i=0;i<a.length;i++)
    {
    odd=1;
    b=a[i];
    for(int j=i+1;j<a.length;j++)
    {
    if(b==a[j])
    {
    odd++;
    }
    }
    if(odd%2!=0)
    break;
    else
    continue;
    }
    return b;
    }
    }