【发布时间】:2016-10-17 11:20:55
【问题描述】:
public static void main (String[] args) {
String pet;
pet = inputString("What pet do you own?");
if (pet.equals("dog"));
{
System.out.println("Dogs are mans best friend!");
}
if(pet.equals("cat"));
{
System.out.println("Cats are very independent");
}
if(pet.equals("lion"));
{
System.out.println("I don't think that should be your pet mate...");
}
}
请帮忙,我的代码没有接受用户的输入,只是打印println 行。还有我如何在这段代码中使用else if。
【问题讨论】:
-
没有您尝试使用的名为
inputString的方法。你想念Scanner的定义吗? -
你检查过你的牙套数量吗?
-
请发布所有代码
-
我已经为你添加了工作代码来回答关于
else if的疑问。请同时查看How to Ask 和minimal reproducible example。
标签: java compiler-errors