How to convert number to binary in java?
4 answer(s)
Answer # 1 #
javaint num = 10;String binary = Integer.toBinaryString(num);System.out.println("Binary: " + binary);
Answer # 2 #
Output: Binary: 1010. You can also use custom logic with bitwise operations for learning purposes.