Così è mooooolto più semplice:
no?codice:public static String toBinary (int n) { String s = (n & 1) != 0 ? "1" : "0"; if ((n >>= 1) != 0) s = toBinary (n) + s; return s; }
Così è mooooolto più semplice:
no?codice:public static String toBinary (int n) { String s = (n & 1) != 0 ? "1" : "0"; if ((n >>= 1) != 0) s = toBinary (n) + s; return s; }
Andrea, andbin.dev – Senior Java developer – SCJP 5 (91%) • SCWCD 5 (94%)
java.util.function Interfaces Cheat Sheet — Java Versions Cheat Sheet