pre-knowledge

Definition

== is an operator to check if variables are equal on the basis of their memory location

same memory java

Compare if values are equal

package ArithmeticOperations;

public class EqualTo {
	void start() {
		int var1 = 0;
		int var2 = 10;
		boolean result = (var1 == var2);
	}

	public static void main(String[] args) {
		new EqualTo().start();
	}
}

Because 0 and 10 are integers saved on different memory locations the result will be: false

 

Add a print statement to test the output, if you don’t know how to do this click here.