Someone is kind enough to explain to me what these two lines of code print in java:
System.out.println(5&6)
System.out.println(2|1)
Someone is kind enough to explain to me what these two lines of code print in java:
System.out.println(5&6)
System.out.println(2|1)
They are bit-level operators, for example:
int a = 5; //a = 101
int b = 6; //b = 110
System.out.println(a&b); //4=100
System.out.println(a|b); //7=111
what it does is take the number 0 as false and 1 with true and complete the operation with the logical operator that you place.
AND or &: needs both true (1) to be true (1).
OR or |: You need one of the two to be true (1) for the operation to be true.