@@ -0,0 +1,750 @@
+public class Solution %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A        Scanner scan = new Scanner(System.in);%0A        int n = scan.nextInt();%0A        scan.close();%0A        %0A        // convert number-%3Ebinary string-%3Echar array%0A        char%5B%5D binary = Integer.toBinaryString(n).toCharArray();%0A        int tmpCount = 0; // count consecutive ones%0A        int maxCount = 0; // running maximum of consecutive ones%0A        for(int i = 0; i %3C binary.length; i++)%7B%0A        %09// reset to 0 if we hit a '0' char%0A            tmpCount = (binary%5Bi%5D == '0') ? 0 : tmpCount + 1; %0A            %0A            // set max%0A            if(tmpCount %3E maxCount)%7B%0A                maxCount = tmpCount;%0A            %7D%0A        %7D%0A        System.out.println(maxCount);%0A    %7D%0A%7D%0A

Create max-consecutive-ones-in-binary-number-2.java