我想知道为什么这不起作用?我一直在看它一段时间,想知道为什么它不起作用。它似乎没有阅读 if 语句。一切对我来说都是正确的,即使你输入了一个像“A5”这样的合法字符串。
System.out.println("PLEASE TYPE IN A COORDINATE, LETTER FIRST, THEN NUMBER.");
System.out.println();
System.out.print("CAPITALS ONLY, PLEASE. ENTER COORDINATE HERE: ");
String placement = scan.next();
String letter = placement.substring(0,1);
String number = placement.substring(1);
System.out.println(letter);
//System.out.println(placement);
System.out.println(number);
String cord[] = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J"};
for(int s = 0; s < cord.length; s++)
{
//System.out.println(cord[s]);
if(cord[s] == letter)
{
System.out.print("yay, it worked");
}
}