HashMap<String, String> apos = new HashMap<String, String>();
apos.put("i'm","I am");
apos.put("can't","cannot");
apos.put("couldn't","could not");
String[] st = new String[]{"i'm","johny"};
Iterator itr = apos.entrySet().iterator();
for (int i = 0; i < st.length; i++) {
while((itr).hasNext()) {
if (itr.equals(st[i]))
{
st[i].replace(st[i],??????(value of the matched key))
}
}
}
I want to compare a string with hashmap and rerplace a word with hashmap value if it matches with its key. Above is what i am trying to do. Could anyone will please help me what i should write in place of key.
Help will be appreciated. Thanks