Operator "==" doesn't work if I make one array manually and other from string using split method. Why?
import java.util.*;
public class MyClass
{
public static void main(String args[])
{
//first array
String[] arr1={"Ram", "Shyam"};
//starting second array by scanning
Scanner sc=new Scanner(System.in);
String s=sc.nextLine();
//input String provided is: Ram Shyam
String [] arr2=s.split(" ");
//so now two exact same arrays created
//so now I tried to compare but ans false
if(arr1[0]==arr2[0])
{
System.out.println("true");
}
else
{
System.out.println("false");
}
}
}
//ans comes false why?