偶数文字のデータファイル内のすべてのラテン語名に含まれるユニークワードの総数を調べようとしています。これは、これまでのコードIです:データファイル内の偶数文字の一意の単語 - Java
public static void main(String[] args) {
int evenWord = 0;
evenWord += countEvenWord(latinName);
System.out.print("Total number of unique even words in Latin names = ");
System.out.println(evenWord);
}
public static int countEvenWord(String name) {
int numberEven = 0;
if(name.length() % 2 == 0) {
String[] person = name.split("[^a-zA-Z]+");
for(String token: sharks) {
numberEven += token.length();
}
}
return numberEven;
}
出力:
Total number of unique even words in Latin names = 297
コードは、すべてのラテン名の中でも、文字の合計数を見つけませんが、私は独特の合計数を見つけたいですデータファイルに含まれる単語。
データファイル:あなたがSet<String>
を使用し、その内の名前を格納する必要が
David Lee:Cephaloscyllium ventriosum
Max Steel:Galeocerdo cuvier
Jimmy Park:Sphyrna mokarren
...
のようになりますカウント –