我想做的是让我的代码将整数转换为基数 2,然后将这些值转换为字符串数组中的元素。我试图避免使用 Integer.toBinary()。如果我能得到一些帮助,那将非常有帮助。
public String[] streamChars(int[] colAvgs)
{
String avgString = Arrays.toString(colAvgs);
String convBases[] = avgString.split(",");
int remainder;
for (int a =0;a<colAvgs.length;a++)
{
remainder = colAvgs[a];
while(remainder>0)
{
remainder = remainder%2;
if ((remainder%2)==0|| (remainder%2)==1)
{
convbases[a] = Integer.toString(remainder);
a++;
}//end if
}//end while
}//end for
return convbases;
}//end streamChars
感谢您的时间!
aluckdog
缥缈止盈
相关分类