i ^= 1;
XOR the value with 1. This gives you both ways (in case you need to flip 0 <--> 1
either way):
0 ^ 1 = 1
1 ^ 1 = 0
More Related Contents:
- Fast algorithm to calculate n! / (q!)^r
- How to make fibonacci method? [closed]
- is there an algorithm to reverse a chosen part of a number? [closed]
- Deciding a Big-O notation for an algorithm
- What is the fastest search algorithm for a list with names and numbers
- Generating all permutations of a given string
- Finding the max/min value in an array of primitives using Java
- Which Java Collection should I use?
- Effective gif/image color quantization?
- Natural sort order string comparison in Java – is one built in? [duplicate]
- Java lambdas 20 times slower than anonymous classes
- Connect 4 check for a win algorithm
- How to calculate elapsed time from now with Joda-Time?
- Picking a random element from a set
- Prime numbers by Eratosthenes quicker sequential than concurrently?
- What would be the fastest method to test for primality in Java?
- Java – Removing duplicates in an ArrayList
- Fast algorithm for searching for substrings in a string
- Parallel execution of directed acyclic graph of tasks
- How to generate a random permutation in Java?
- What is a good solution for calculating an average where the sum of all values exceeds a double’s limits?
- Intersection of two strings in Java
- In Java, how do I efficiently and elegantly stream a tree node’s descendants?
- Flatten nested arrays in java
- Generate Random Numbers in Array [duplicate]
- How to determine if binary tree is balanced?
- Algorithm – How to delete duplicate elements in a list efficiently?
- Determine the most common occurrence in an array
- Hash : How does it work internally?
- What is the algorithm for finding the center of a circle from three points?