0
所以我做了这个扫描器,我想它取1〜3的字符串。 1为串的最小数目可以采取和3为最大数量。到目前为止,我的输出是:扫描仪取1-3的话
You can search 1 - 3 words only : 3
Type a name: word1
Type a name: word2
Type a name: word3
取而代之的,是有办法,我可以在多个阵列这些话,由于我的程序将要执行复式字符串搜索。
public static void main(String[]args) throws IOException{
int nnames;
String[] stringSearch;
System.out.print("You can search 1 - 3 words only : ");
Scanner in = new Scanner(System.in);
nnames = Integer.parseInt(in.nextLine().trim());
stringSearch = new String[nnames];
for (int i = 0; i < stringSearch.length; i++){
System.out.print("Type a name: ");
stringSearch[i] = in.nextLine();
}
“[我想]有这些单词在多个数组中,由于我的程序将执行多字符串搜索的事实。”对不起,我不明白这个部分。为什么你需要多个数组来执行多个字符串搜索?真的,如果你只是将它们传递给一个'void performSearch(string)'方法,它应该不会影响字符串的存储位置。 – Kevin
你想有为了许多阵列以避免锁定?如果是,那么在搜索中没有锁定。它是只读的(主要)。 –
你能告诉我们什么是你需要搜索的字符串,在这里您将搜索呢? 你走这三个字,并在多个文本看呢? – igorrs