Example usage for java.lang Integer toBinaryString

List of usage examples for java.lang Integer toBinaryString

Introduction

In this page you can find the example usage for java.lang Integer toBinaryString.

Prototype

public static String toBinaryString(int i) 

Source Link

Document

Returns a string representation of the integer argument as an unsigned integer in base 2.

Usage

From source file:MainClass.java

public static void main(String[] arg) {
    System.out.println(Integer.toBinaryString(100));

}

From source file:Main.java

public static void main(String[] args) {

    System.out.println(Integer.toBinaryString(10));
    System.out.println(Integer.toBinaryString(-10));

    System.out.println(Integer.toBinaryString(10000));
    System.out.println(Integer.toBinaryString(-10000));
}

From source file:Main.java

public static void main(String[] args) {
    int i = 78;//w w  w . j  a  va2 s.  c  o m

    String strBinaryNumber = Integer.toBinaryString(i);
    System.out.println(strBinaryNumber);
}

From source file:Main.java

public static void main(String[] args) {
    int integer = 127;
    String binary = Integer.toBinaryString(integer);
    System.out.println("Binary value of " + integer + " is " + binary + ".");

    int original = Integer.parseInt(binary, 2);
    System.out.println("Integer value of binary '" + binary + "' is " + original + ".");
}

From source file:Main.java

public static void main(String[] args) throws Exception {

    int i = 42;/*from ww  w  .j  a  v  a  2s.  c o  m*/
    String bin = Integer.toBinaryString(i);
    System.out.println(bin);
}

From source file:Main.java

public static void main(String args[]) {
    int num = 19648;

    System.out.println(num + " in binary: " + Integer.toBinaryString(num));

    System.out.println(num + " in octal: " + Integer.toOctalString(num));

    System.out.println(num + " in hexadecimal: " + Integer.toHexString(num));
}

From source file:WrapperDemo.java

public static void main(String[] args) {
    System.out.println("16055 in binary: " + Integer.toBinaryString(16055));

}

From source file:MainClass.java

public static void main(String args[]) {
    int i = 11;
    System.out.println("Binary is " + Integer.toBinaryString(i));
}

From source file:Main.java

public static void main(String[] argv) {
    // Using  a  lambda  expression
    Function<Integer, String> func1 = x -> Integer.toBinaryString(x);
    System.out.println(func1.apply(10));

    // Using  a  method  reference
    Function<Integer, String> func2 = Integer::toBinaryString;
    System.out.println(func2.apply(10));
}

From source file:Main.java

public static void main(String[] args) {
    IntStream i = IntStream.of(6, 5, 7, 1, 2, 3, 3);
    Stream<String> d = i.mapToObj(n -> Integer.toBinaryString(n));
    d.forEach(System.out::println);
}