I have a Linkedhashmap called numericValueMap that has the parameters String,String:
{a=1,b=1,c=2,d=3,e=5}
And I have an Arraylist called equation:
{ e, -, a, +, b, -, c, *, d, +, b}
What I want to do is replace the items in the Arraylist with the correct Values from the Linkedhashmap. Here is my attampt so far:
for (final String key: numericValueMap.keySet()) {
for (int i = 0, n = equation.size(); i < n; i++) {
String algebraItems = (String) equation.get(i);
if(algebraItems.contains(key)) {
String newNum = algebraItems.replace(algebraItems, ?);
equation.set(i,newNum);
}
}
}
The code works up until and including the point where it compares the Arraylist to the corresponding Linkedhashmap Key. However with my current knowledge, I am unable to replace the Arraylist item with the correct Value. Any ideas on what code I must use?