下面是apples.java,其中有字符串fName = input.nextLine();
class apples {
public static void main(String args[]) {
Scanner input = new Scanner(System.in);
Yeet YeetObject = new Yeet();
System.out.println("Hello user!, please enter your first name: ");
String fName = input.nextLine();
YeetObject.firstName(fName);
}
}
下面是Yeet.java,它的意思是说“你好,亚历山大”而不是“错误的人”
public class Yeet {
public void firstName(String fName) {
if (fName == "Alexander") {
System.out.println("Hello, " + fName);
} else {
System.out.println("Wrong Person!!!");
}
}