Java中怎么把一串二进制转换成数组呢?
列入有000000111
转换成
000
000
111
我只写到了将任意十进制转换成二进制- -
求大神指点指点
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Scanner;
public class Conversation {
public static void main(String args[]){
Scanner input = new Scanner(System.in);
System.out.print("请输入二进制数字: ");
int m=input.nextInt();
toBinary(m);
}
static void toBinary(int num){
if(num/2==0){
int w = num%2;
System.out.print(w+" ");
}
else{
int w = num%2;
toBinary(num/2);
System.out.print(w+" ");
}
}
}