How to append string to StringBuffer in Java

1 Answer

0 votes
package javaapplication1;

import java.io.IOException;

public class JavaApplication1 {

    public static void main(String[] args) throws IOException {

	StringBuffer buffer = new StringBuffer();

	for (int i = 0; i < 5; i++) {
	    buffer.append(i).append('-').append("abc  ") ;
	}
	System.out.println(buffer);
    }
}


/*

run:
                   
0-abc  1-abc  2-abc  3-abc  4-abc  
          
 */

 



answered Dec 20, 2016 by avibootz
edited Jan 10, 2017 by avibootz

Related questions

1 answer 235 views
1 answer 208 views
2 answers 243 views
1 answer 105 views
1 answer 233 views
1 answer 215 views
215 views asked Jan 20, 2022 by avibootz
...