简体   繁体   中英

How can i do a java iterator to print out an array

I'm not quite sure how iterators work or how to call them in my main, how can I do this???

It's not exactly clear what you're asking. But if your intent is to convert an expression such as "5*3+2" into an expression tree using recursion then here's an approximate algorithm in pseudo code (ignoring any precedent as you didn't ask about that):

function getExpressionTree(expr): Node
    if (expression has operator)
        create new node with operator
        node's left operand = getExpressionTree(substring before operator)            
        node's right operand = getExpressionTree(substring after operator)
        return node
    else
        return constant node from expression

There are plenty of issues in the code you've posted but given you've just asked for general help I'm hoping the algorithm above can get you started.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM