Java:同样的项目,同样的包,同样的代码,只有两个类的类名不一样,为什么测试结果不一样???见图 100
false的代码:importjava.util.Scanner;publicclassGame{publicstaticvoidmain(String[]args){S...
false的代码:
import java.util.Scanner;
public class Game {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String line;
String[] words;
while ( true )
{
line = in.nextLine();
words=line.split(" ");
System.out.println(words[0]);
System.out.println(words[1]);
System.out.println(words[0].equals("go"));
if (words[0].equals("go"))
System.out.println(111111);
if (words.equals("help"))
System.out.println(2222222);
}
}
} 展开
import java.util.Scanner;
public class Game {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String line;
String[] words;
while ( true )
{
line = in.nextLine();
words=line.split(" ");
System.out.println(words[0]);
System.out.println(words[1]);
System.out.println(words[0].equals("go"));
if (words[0].equals("go"))
System.out.println(111111);
if (words.equals("help"))
System.out.println(2222222);
}
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询