String

I am writing a program, to add certain number of COMMAs with a string but I am not getting my desire result, it is just showing a single COMMA "," instand of "ABCD,,,". I don,t know why input=input+","; is not working correctly.

String input;
input = "ABCD"
for(int i=0 ; i<3; i++); {
    input = input + ",";
    }
println (input);
Tagged:

Answers

  • Your issue is not with commas, but with semicolons. Specifically, you have one where you shouldn't and don't have one where you should.

    String input;
    input = "ABCD";
    for(int i=0 ; i<3; i++) {
        input = input + ",";
        }
    println (input);
    
  • Duplicate of Struggling with JOIN command. Avoid making duplicate threads.

This discussion has been closed.