Java skipping a comparison entirely

Any idea why this code would skip line 13 even when i=1 charAt(i) is 0 and if comparison should be true and increment count. But it would never get in there. So confused.

public class test {

   public static void main (String[] args) {

      solution(1041);

   }

   public static void solution(int N) {

        String bin = Integer.toBinaryString(N);

        int count = 0;

        int max = 0;

        char zero = 0;

       

        for(int i=0;i
        {

            if(bin.charAt(i) == zero)

            {

                count++;

            }

            else

            {

                if (count > max)

                    max = count;

                count = 0;

           ...

Read More »

By: coderanchbeginnerjava - Saturday, 21 July

Related Posts