Java 无法从InputStreamReader中的System.in返回结果
我在返回颜色字符串时遇到问题。出于某种原因,它不会返回num。我不确定是否需要用else插入if语句的结尾,但我觉得这就是catch语句if的用途 主类 测试班Java 无法从InputStreamReader中的System.in返回结果,java,inputstreamreader,system.in,Java,Inputstreamreader,System.in,我在返回颜色字符串时遇到问题。出于某种原因,它不会返回num。我不确定是否需要用else插入if语句的结尾,但我觉得这就是catch语句if的用途 主类 测试班 您的代码示例运行良好。我在测试中添加了以下行,并按预期打印颜色: public static void main(String[] args) { Computer a = new Computer(); System.out.println(a.getProcessor()); } 根据需要打印蓝色或红色 package e
您的代码示例运行良好。我在测试中添加了以下行,并按预期打印颜色:
public static void main(String[] args) {
Computer a = new Computer();
System.out.println(a.getProcessor());
}
根据需要打印蓝色
或红色
package edu.computer.test;
public class ComputerTester {
public static void main(String[] args) {
Computer a = new Computer();
a.getProcessor();
}
}
public static void main(String[] args) {
Computer a = new Computer();
System.out.println(a.getProcessor());
}