java - 变量应由java中的某些控制台输入填充
问题描述
当我通过扫描仪输入在控制台 26 中键入时,java 中是否有任何可能性,它会自动在 if 语句中用它们各自的值填充 t2 和 t3?(t2 应该是 3,t3 应该是 2020)
Scanner in = new Scanner(System.in);
String s = in.nextLine();
int t = Integer.parseInt(s);
System.out.println((Arrays.asList(t, t2, t3)));
解决方案
我不完全确定你的问题。这是你要求的吗?
Scanner in = new Scanner(System.in);
String s = in.nextLine();
int t = Integer.parseInt(s);
if (t == 26) {
t2 = 3; // assumed that t2 and t3 are int
t3 = 2020;
}
推荐阅读
- syslog - Rundeck 2.10:如何远程记录到系统日志
- r - 根据多个条件汇总计数
- blazor - 从数据库中选择的 Blazored Typeahead 导入值
- redux - 是在 redux 传奇中阻止 takeEvery 吗?
- uml - 加入节点还是合并节点?
- azure - Azure 身份验证(经典):AAD 多个颁发者 url
- c++ - Boost::asio get_io_service() 在 boost 1.70+ 中的替代品
- azure - 允许 Exchange 混合设置的 Azure 防火墙规则/IP
- javascript - 如何在android中通过URL传递信息。Android 识别“?”之后的部分 作为文件名的一部分
- datastage - 我们可以从 DataStage Jobs 生成数据沿袭吗?