package com.test2;
public class Demo6 {
static int count=0;
private void Method1(int number){
if(number%2==1){
count++;
}
if(number!=0){
Method1((int)(number/2));
}else{
return;
}
}
public static void main(String[] args) {
Demo6 d6 = new Demo6();
d6.Method1(111);
System.out.println(count);
}
}
你自己测试测试