In this tutorial, we are going to write a Java program to use the equal function in Java Programming with practical program code and step-by-step full complete explanation.

java program to use equal function


Java program to use the equal function.

 
import java.awt.*;
import javax.swing.*;

public class Inp
{
    public static void main(String arr[])
    {
        int i=4,j=5;

        System.out.println("hello :"+i);
        System.out.println(i+j);
        
        String S1=new String ("india");
        String S2="india";

        if(S1==S2)
            System.out.print("comparing String using++operator");
        if(S1.equals(S2))
            System.out.print("comparing String using equal method");
    }
}


Output

 
hello : 4
9
comparing String using equal method