This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I saw your question in the forums at Sun's website too.
First of all, you need to get exactly clear what you want. You have two strings containing two operators, for example "*" and "+". Now what output exactly do you want?
Do you just want to know which of the two has the highest priority, for example?
You have to write a piece of code that contains a data structure to keep track of the priorities of the different operators, and then you need to lookup the priorities of the two you want to compare. For the data structure, try a HashMap. For example (uses Java 5.0 features):
Your "for" loop loops over every character in "infixStr", but the HashMap only contains entries for a few characters. When the loop hits a character not in the Map, you'll see this exception. So you need to check whether a given character is an operator or not, first. You could just split this line into two and not use auto-unboxing: