How to set binary value with underscores to an integer in Java

2 Answers

0 votes
public class MyClass {
    public static void main(String args[]) {
        int x = 0b1011_0001;

        System.out.println(x);
    }
}



/*
run:

177

*/

 



answered May 26, 2019 by avibootz
0 votes
public class MyClass {
    public static void main(String args[]) {
        int x = 0b10_11_00_01;

        System.out.println(x);
    }
}



/*
run:

177

*/

 



answered May 26, 2019 by avibootz

Related questions

1 answer 141 views
1 answer 165 views
1 answer 174 views
1 answer 198 views
1 answer 186 views
1 answer 179 views
3 answers 258 views
...