Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pmatsinopoulos/1738d8d18bd2217807c5c2e4b71e9a58 to your computer and use it in GitHub Desktop.
Save pmatsinopoulos/1738d8d18bd2217807c5c2e4b71e9a58 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class IntegerToBinary {
public static void main(String[] args) {
System.out.print("Give me an integer number: ");
Scanner scanner = new Scanner(System.in);
if (scanner.hasNextInt()) {
int integer = scanner.nextInt();
System.out.printf("Binary: %s\n", Integer.toString(integer, 2));
}
scanner.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment