我有一个集合 Map 作为(字符串,字符串)和字符串 inputText。您建议扫描 inputText 以检查它是否包含 Map 中的任何键。
例如,我有下一个:
//hashmap is used - I don't need the order
Map<String, String> mapOfStrings = new HashMap<String,String>();
mapOfStrings.put("java","yep, java is very useful!");
mapOfStrings.put("night","night coding is the routine");
String inputText = "what do you think about java?"
String outputText = ""; //here should be an <answer>
Set<String> keys = mapOfStrings.keySet();
for (String key:keys){
String value = mapOfStrings.get(key);
//here it must uderstand, that the inputText contains "java" that equals to
//the key="java" and put in outputText the correspondent value
}
据我所知,它不是 equals() 或 compareTo()。也许我应该以某种方式检查 inptuText 中的字符顺序?
问候