Java does have a logical XOR operator, it is ^ (as in a ^ b
).
Apart from that, you can’t define new operators in Java.
Edit: Here’s an example:
public static void main(String[] args) { boolean[] all = { false, true }; for (boolean a : all) { for (boolean b: all) { boolean c = a ^ b; System.out.println(a + " ^ " + b + " = " + c); } } }
Output:
false ^ false = false false ^ true = true true ^ false = true true ^ true = false
Related Posts:
- What does “|=” mean? (pipe equal operator)
- The difference between += and =+
- What is a Question Mark “?” and Colon “:” Operator Used for?
- What does the colon (:) operator do?
- Java Not Greater than Or Equal to Operator for Char Type
- What is inverse function to XOR?
- Exception in thread “main” java.util.NoSuchElementException
- “Error occurred during initialization of VM; Could not reserve enough space for object heap” using -Xmx3G
- What’s the simplest way to print a Java array?
- javax vs java package
- What is a stack trace, and how can I use it to debug my application errors?
- How to fix “A JNI error has occurred, please check your installation.”
- Java Runtime Environment not found error when I open an application
- “PKIX path building failed” and “unable to find valid certification path to requested target”
- What exactly does a jar file contain?
- JRE Missing when installing eclipse
- What does “?” mean in Java? [duplicate]
- When is the @JsonProperty property used and what is it used for?
- Print ArrayList
- “Missing return statement” within if / for / while
- Understanding regex in Java: split(“\t”) vs split(“\\t”) – when do they both work, and when should they be used
- Make copy of an array
- How can I use ant
to execute commands on linux? - Invalid initial heap size -Xms4096M
- How do I use a PriorityQueue?
- What does Java option -Xmx stand for?
- How can I convert a .jar to an .exe?
- Error: NoClassDefFoundError: org/apache/commons/logging/LogFactory
- Illegal Escape Character “\”
- Error – trustAnchors parameter must be non-empty
- Calculating the angle between the line defined by two points
- Wait for page load in Selenium
- What does regular expression \\s*,\\s* do?
- Constructor cannot be applied to given types?
- Printing HashMap In Java
- Java “.class expected”
- Java Initialize an int array in a constructor
- How Exactly Does @param Work – Java
- Return string Input with parse.string
- Android ListView headers
- What does -XX:MaxPermSize do?
- No enclosing instance of type is accessible.
- How to remove single character from a String
- What is the best math library to use with java?
- What is the difference between a null array and an empty array?
- Why is there no String.Empty in Java?
- How to initialize List
object in Java? - PrintWriter append method not appending
- Using ADB to capture the screen
- What is the difference between response.sendRedirect() and request.getRequestDispatcher().forward(request,response)
- Recursion vs. Iteration (Fibonacci sequence)
- What is difference between Errors and Exceptions?
- What is the difference between Integer and int in Java?
- Netbeans installation doesn’t find JDK
- Convert String to int array in java
- eclipse won’t start – no java virtual machine was found
- What causes “‘void’ type not allowed here” error
- Variable might not have been initialized error
- Java substring: ‘string index out of range’
- throw checked Exceptions from mocks with Mockito
- How to sort an array of objects in Java?
- Android – SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
- Hibernate Error: a different object with the same identifier value was already associated with the session
- How to solve the “failed to lazily initialize a collection of role” Hibernate exception
- Initializing multiple variables to the same value in Java
- Java: Unresolved compilation problem
- FXML Load exception
- NullPointerExcetion Native Method Accessor… Hashing Words Issue
- How to convert currentTimeMillis to a date in Java?
- How to clear console in Java – Eclipse
- Java TreeMap Comparator
- Get keys from HashMap in Java
- Determine if a String is an Integer in Java [duplicate]
- How do I run Java .class files?
- Fill an array with random numbers [duplicate]
- Connection Java – MySQL : Public Key Retrieval is not allowed
- Whitespace Matching Regex – Java
- Size has private access in ArrayList
- Iterator for a linkedlist
- Hide Utility Class Constructor : Utility classes should not have a public or default constructor
- Android – Start service on boot
- JsonMappingException: No suitable constructor found for type [simple type, class ]: can not instantiate from JSON object
- Sending POST data in Android
- When is “java.io.IOException:Connection reset by peer” thrown?
- Regex pattern including all special characters
- Error: ‘)’ expected compiler error
- How does addNotify() and requestFocus() work in Java with JPanel?
- DTO and DAO concepts and MVC
- How to extract .war files in java? ZIP vs JAR
- What is the difference between run-time error and compiler error?
- What is the difference between ArrayList.clear() and ArrayList.removeAll()?
- Test if element is present using Selenium WebDriver?
- Increase heap size in Java
- android.content.res.Resources$NotFoundException: String resource ID #0x0
- what does x– or x++ do here?
- How to print a table of information in Java
- set background color: Android
- Class Declarations for temperature program in Java
- Spring Boot – Cannot determine embedded database driver class for database type NONE
- Convert double to float in Java