Skip to main content

Can be achieved using stream API in java 8 and above

public static boolean logicalXOR(boolean x, boolean y) { // can modify to take [] or list of bools return Stream.of(x, y) // modify as per method params .filter(bool -> bool) .count() == 1; } 
public static boolean logicalXOR(boolean x, boolean y) { // can modify to take [] or list of bools return Stream.of(x, y) // modify as per method params .filter(bool -> bool) .count() == 1; } 

Can be achieved using stream API in java 8 and above

public static boolean logicalXOR(boolean x, boolean y) { // can modify to take [] or list of bools return Stream.of(x, y) // modify as per method params .filter(bool -> bool) .count() == 1; } 

Can be achieved using stream API in java 8 and above

public static boolean logicalXOR(boolean x, boolean y) { // can modify to take [] or list of bools return Stream.of(x, y) // modify as per method params .filter(bool -> bool) .count() == 1; } 
update answer
Source Link
Harsh Gundecha
  • 1.2k
  • 11
  • 16

Can be achieved using stream API in java 8 and above

public static boolean logicalXOR(boolean x, boolean y) { // can modify to take [] or list of bools return Stream.of(x, y) // modify per ofas toper method params .filter(bool -> bool) .count() == 1; } 

Can be achieved using stream API in java 8 and above

public static boolean logicalXOR(boolean x, boolean y) { // can modify to take [] or list of bools return Stream.of(x, y) // modify per of to method .filter(bool -> bool) .count() == 1; } 

Can be achieved using stream API in java 8 and above

public static boolean logicalXOR(boolean x, boolean y) { // can modify to take [] or list of bools return Stream.of(x, y) // modify as per method params .filter(bool -> bool) .count() == 1; } 
Source Link
Harsh Gundecha
  • 1.2k
  • 11
  • 16

Can be achieved using stream API in java 8 and above

public static boolean logicalXOR(boolean x, boolean y) { // can modify to take [] or list of bools return Stream.of(x, y) // modify per of to method .filter(bool -> bool) .count() == 1; }