I don't get it why my arrays don't concatenate,its just that when I concatenate my arrays with any other character, it doesn't show the content of the tempString. But when I remove the special characters, it produces the output.
E.G When there is no special character, the output is //ThisisaSingleLineComment But when I use other special characters, there is no output at all
The Codes I used are the ff.:
tempString=tempString+newTokens[ctr];
tempString+=newTokens[ctr];
I even used string builder with this code, still there is no output.
StringBuilder sb = new StringBuilder(100);
sb.append(newTokens[ctr]);
sb.append(whiteSpace);
My output should look like this // This is a Single Line Comment
Since each and every one of those are assigned in an array that I want to combine to form a single string / queue(stack) value.
Why not using String#join
String[] newTokens ={"This","is","a","Single","Line","Comment"};
System.out.println(String.join(" ",newTokens));
And, output is
This is a Single Line Comment
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With