What is the best way to invert a bit of a whole number in Java? I have tried it in the following way, although it seems inelegant to me:
int entero = 4+2+1;
if ((entero & 4) == 4)
entero -= 4;
else
entero += 4;
System.out.println ("Entero con el bit 3 invertido: " + entero);