check if two variable not equal in java
Code snippet on how to check if two variable not equal in java
if (variable1 != variable2) {
System.out.println("The two variables are not equal.");
}
This code checks whether two variables (variable1 and variable2) are equal or not. The code begins with an if statement that checks whether the two variables are not equal (meaning that the values stored in each variable are different) by using the β!=β operator. If the statement is true (meaning that the two variables hold different values), then the code inside the curly brackets is executed, which prints out a message to the console. If the statement is false (meaning that the two variables have the same value), then nothing is executed. In this case, the code prints out a message to the console that reads βThe two variables are not equal.β