我有下面的代碼。匹配一個字母的單詞
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