我有下面的代码。匹配一个字母的单词
import java.io.File;
import java.util.ArrayList;
import java.util.Scanner;
public class Dummy {
public static void main(String args[]) throws Exception {
String word="hi";
String[] one={"a","b","c"};
String[] two={"d","e","f"};
String[] three={"g","h","i"};
String[] four={"j","k","l"};
String[] five={"m","n","o"};
String[] six={"p","q","r","s"};
String[] seven={"t","u","v"};
String[] eight={"w","x","y","z"};
for(int i=0;i<word.length();i++)
{
for(int j=0;j<three.length;j++)
{
if(three[j].equals(word.charAt(i)))
{
System.out.println("Matched");
}
else
{
System.out.println("err");
}
}
}
}
}
在这里,我的概念是匹配字符串中的一个字母到创建的数组,这里的输出是所有错误(条件说明不匹配)。请让我知道我哪里错了。
谢谢
非常感谢你,这是有帮助的,我想知道是否有办法我可以得到数组名称。像匹配和数组是三 – user2423959