java - 如何在 if 语句中使用字符串?
问题描述
注意:抱歉格式错误,我是堆栈溢出的新手
如果我有一段这样开头的代码,
import java.util.Scanner;
public class MyProgram
{
public static void main(String[] args)
{
Scanner Input = new Scanner (System.in);
System.out.println( "Write either yes or no." );
String message = Input.nextLine();
我正在考虑这样的事情:
if( message == "yes" )
我的意思是检查用户在提示时写的内容,这些内容存储为消息。
解决方案
推荐阅读
- amazon-web-services - 无法安装/使用 AWS 工具 Powershell cmdlet
- php - 在 PHP 中排队作业
- python - 在 VPS 上使用 python 套接字的 winerror 10061
- powershell - 简单查询在 Powershell_ISE 中不起作用,但在 Powershell 上不起作用
- javascript - 文档的 Firestore 数据聚合
- python - 使用 pool.map 进行多处理时无法腌制本地对象
- excel - Excel计算最高颜色值
- asp.net-core - Asp net core env vars不适用于array-within-array appsettings Serilog属性
- php - 运行 docker-php-ext-install pdo mcrypt mbstring 时出错
- python - 当 ORTOOLS 提出解决方案时评估自定义函数