+ 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); } }

9th Mar 2017, 7:40 AM
Prabhakar Dev
Prabhakar Dev - avatar
3 odpowiedzi
+ 7
ok
9th Mar 2017, 1:35 PM
Prabhakar Dev
Prabhakar Dev - avatar
+ 4
When I run it, the output shows that- 'non-static variable m can't be referred from a static context
9th Mar 2017, 8:28 AM
Prabhakar Dev
Prabhakar Dev - avatar
+ 3
try making the binary method static
9th Mar 2017, 12:41 PM
seamiki
seamiki - avatar