Check out example codes for "equals example java". It will help you in understanding the concepts better.

Code Example 1

String str = "abc";
String str1 = "abc";
// returns true if str and str1 are exactly same otherwise false

Code Example 2

import java.util.Scanner;

public class YourProjectName {

	public static void main(String[] args) {
		Scanner keyboard = new Scanner(;
		String password1;
		String password2;
		String msg;
		System.out.println("Enter password: ");
			password1 = keyboard.nextLine();
		System.out.println("Repeat password: ");
			password2 = keyboard.nextLine();
		if (password1.equals(password2)) {
			msg = "Password matching!";
		} else {
			msg = "Password not match";


Learn ReactJs, React Native from