Use Bitwise complement operator in Java
Description
The following code shows how to use Bitwise complement operator.
Example
/*w w w . ja v a 2s .c o m*/
public class Main {
public static void main(String[] a) {
int i = 1;
System.out.println(i);
int j = ~i + 1;
System.out.println(j);
i = ~j + 1;
System.out.println(i);
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »