【发布时间】:2020-08-22 09:18:19
【问题描述】:
我只是一名副程序员,为一些额外的硬币做一些小项目。没什么大不了的。
但是我得到了这段代码,其中包含我试图在 Android Studio 上的 GUI 上运行的 if 和 else if 语句,我希望代码显示在实际的 android 应用程序中。我不知道将代码放在哪里或如何在 .java 文件中调用它,以便它可以在 Studio 程序的 android 应用程序中运行。我希望也许对 Android Studio 有更多经验的人可以帮助我弄清楚我的下一步是什么。如果我对我的问题含糊不清,我深表歉意,我不太擅长解释这个问题。
public class Main {
public static void main(String[] args) {
String lit;
Scanner scan = new Scanner(System.in);
System.out.println("Set the thermostat to call for heating, does the pilot stay lit? y/n");
lit = scan.nextLine();
if (lit.equals("y")) {
System.out.println("Great. So it works.");
} else if (lit.equals("n")) {
System.out.println("Check the thermocouple.");
}
}
}
【问题讨论】:
标签: javascript java android android-studio