我需要检查作为输入提供的拼写是否正确,但是它没有输入我的if语句中。
我能够验证变量word是否正确获得了“ RAINBOW”,但是为什么我不参与if语句中的验证
import java.util.Scanner;
class Character
{
public static void main(String[] args)
{
String first;
String second;
String third;
String fourth;
String fifth;
String sixth;
String seventh;
String word;
Scanner sc=new Scanner(System.in);
System.out.println("Enter the first letter");
first=sc.next();
System.out.println("Enter the second letter");
second=sc.next();
System.out.println("Enter the third letter");
third=sc.next();
System.out.println("Enter the fourth letter");
fourth=sc.next();
System.out.println("Enter the fifth letter");
fifth=sc.next();
System.out.println("Enter the sixth letter");
sixth=sc.next();
System.out.println("Enter the seventh letter");
seventh=sc.next();
word =first+second+third+fourth+fifth+sixth+seventh;
if(word=="RAINBOW")
System.out.println(word);
else
System.out.println("Wrong");
}
}