I have a multidimension arrayList and I ask the user for a formula and than I evaluate it. The problem is that I get user input like this:
((a1+a2)/12)*a3
An alternative to Heisenbug's suggestion is to try Dijkstra's shunting-yard algorithm. Instead of relying on a tree structure, you use stacks and queues. The advantage is that these data structures involved are not terribly complicated. The downside is that any errors in implementing the algorithm could be easily missed, as you need to thoroughly understand the operations involved to know if your implementation is correct.