+ 7
I didn't understand the problem
public class Program { public String binary(int n){ int b,x=0; String c=""; while(x<1){ b=n%2; if(b==1){ c.concat("1"); n/=2; if(n==1){ ++x; }} else{ c.concat("0"); n/=2; if(n==1){ ++x; } } } return c; } public static void main(String[] args) { int v=6; String m=binary(v); System.out.println(m); } }
3 Answers
+ 7
ok
+ 4
When I run it, the output shows that- 'non-static variable m can't be referred from a static context
+ 3
try making the binary method static