import java.util.*;
import java.lang.*;
class password
{
    public static void main(String[] args)
    {
        int i;
        String pass,temppass;
        Scanner s=new Scanner(System.in);
        System.out.println("Enter Password: ");
        pass=s.next();
        System.out.println("Re-enter password: ");
        temppass=s.next();
        if(temppass==pass)
        {
            System.out.println("Sucess");
        }
        else
            System.out.println("failed");
    }
}
I wrote this basic code in Java to match my password input. Even if I enter the correct password, it goes to the else statement, i.e. "failed". What should I do now?
 
     
     
     
    