Concatenating a list into a string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jtanz0
    New Member
    • Jan 2008
    • 4

    #1

    Concatenating a list into a string

    Hi,

    I am trying to convert infix notation to postfix notation, so far i have been quite successfull but in order to move on to the next part of the program (RPN calculator) i need to take all the elements in the Array list i have of all the operators and operands (in the right order) and concatinate them to form a string and i am finding it fairly difficult if anyone can shed any light on how this can be done i would be very greatfull

    thanks

    Jon
  • Laharl
    Recognized Expert Contributor
    • Sep 2007
    • 849

    #2
    Create an empty string, move through the ArrayList, and use the + concatenation operator to append each element to said string by using its toString() method.

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      Google is your friend here.

      kind regards,

      Jos

      Comment

      • BigDaddyLH
        Recognized Expert Top Contributor
        • Dec 2007
        • 1216

        #4
        Originally posted by Laharl
        Create an empty string, move through the ArrayList, and use the + concatenation operator to append each element to said string by using its toString() method.
        To optimize this, you could use a StringBuilder instead of String and append methods instead of + or +=.

        Comment

        • jtanz0
          New Member
          • Jan 2008
          • 4

          #5
          thanks people all done

          Comment

          Working...