Check out example codes for "java 51 variable error". It will help you in understanding the concepts better.

Code Example 1

public static Rand searchCount (int[] x) 
{
    int a ; 
    int b ; 

    ...   

    for (int l= 0; l<x.length; l++) 
    {
        if (x[l] == 0) 
        a++ ;
        else if (x[l] == 1) 
        b++ ;
    }

    ...   

}

Learn ReactJs, React Native from akashmittal.com