如果我有两个句子,例如)“我是男孩。” “我是学生。”
如何将它们更改为整数,然后编写代码来搜索并计算重复出现的单词?
Ex) 有两个“I”,有两个“am”,有两个“a”
public class StringEx {
public static void main(String[] args) {
String text = "I am a boy";
String text2 = " I went to the store to buy a bag of potato";
String[] temp = text.split(" ");
System.out.println(temp.length);
for (int i = 0; i < temp.length; i++) {
System.out.println(temp[i] + "");
}
int nText = Integer.parseInt(temp); //I don't know what do here
System.out.println(nText);
}