Published
- 1 min read
Java make sure only one condition is true
The solution for this is noted below
Java make sure only one condition is true
Solution
if (Stream.of(valueA, valueB, valueC, valueD).filter(Objects::nonNull).count() != 1) {
/* throw error */
}
Try other methods by searching on the site. That is if this doesn’t work