我正在计算单词,而我的增量运算符没有增加 即使与相似的单词匹配。输出就像这样
Enter a paragraph to check number of words and its frequency
rahul rahul rahul
rahul 0
rahul 0
rahul 0
Scanner y = new Scanner(System.in);
System.out.println("Enter a paragraph to the words and its frequency\n");
String para = y.nextLine();
String a = para.toLowerCase();
String array[] = a.split(" ");
int l = array.length;
int count[];
count = new int[1000];
for (int i = 0; i < l; i++) {
for (int j = i + 1; j < l; j++) {
if (array[i] == array[j]) {
count[i]++;
}
}
System.out.print(array[i] + " ");
System.out.println(count[i]);
}