class ToBin1
{
public static void main(String[] args)
{
System.out.println(toBin(14));
}
public static String toBin(int n)
{
StringBuffer sb=new StringBuffer();
while (n>0)
{
int a=n%2;
sb.append(a);
n/=2;
}
StringBuffer sb1=sb.reverse();
return sb1.toString();
}
}
|
|