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 217 views
1 answer 253 views
1 answer 248 views
1 answer 275 views
1 answer 270 views
1 answer 268 views
3 answers 371 views
...