gpt4 book ai didi

Java 扫描器代码 If-then-else

转载 作者:行者123 更新时间:2023-11-29 05:28:39 26 4
gpt4 key购买 nike

<分区>

我的 if-then-else 语句总是输出 else 结果

import java.util.Scanner;


public class NiallScanner {

public static void main(String[] args)
{
System.out.println("Hello, What is your name?");
Scanner scanner = new Scanner(System.in);
String yourName = scanner.nextLine();
System.out.println("Is your name: "+yourName + "?");

Scanner scanner1 = new Scanner(System.in);
String isCorrect = scanner1.nextLine();

if (isCorrect == "Yes")
{
System.out.println("Thank you for your confirmation!");
}
else
{
System.out.println("Retry please.");

}

}

伙计们有什么想法吗?顺便说一句,我是 java 的新手,所以我可能会忽略基本的编码错误。

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com