Skip to content
Advertisement

appending arguments to a String

I need to write a simple Java program so as to step through a given string (given from args[]), and receive a println once a certain character (e.g. ‘^’) is encountered. However, I cannot find why I cannot receive such println. Could you please check what is the stem of the error?

JavaScript

Advertisement

Answer

You’re creating a new StringBuffer with every iteration of your loop. You should use a StringBuilder. And you need to start at args.length - 1. Finally >= 0 like ,

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement