Tilda operator:
The ~ operator performs a bitwise complement operation on its operand, which has the effect of reversing each bit. Bitwise complement operators are predefined for int, uint, long, and ulong.

RemarksRemarks
 

User-defined types can overload the ~ operator. For more information, see operator. Operations on integral types are generally allowed on enumeration.

 

The time of writing this manuscript, Iteraror in Java 5.0 was introduced, that was an equivalent to foreach loop of C#

import java.io.*;
// javac operator_tilda.java
//also show how to use arrays
public class operator_tilda
{
public static void main(String args[])throws IOException
{
int[] values = { 0, 0x111, 0xfffff, 0xFF0000, 0x22000022};
String[] str = { "one", "two", "three", "four", "five"};
for(int i = 0; i< 5; i++)
{
// System.out.println("~ with int array : "+ values[i]);
System.out.println("simple array " + values[i] + "\t~values[i] array : "+ ~values[i]);
}
for(int i = 0; i< 5; i++)
{
System.out.println("string "+ str[i]);
}
}
}