How to append int numbers 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 < 10; i++) {
	    buffer.append(i).append(' ');
	}
	System.out.println(buffer);
    }
}


/*

run:
                   
0 1 2 3 4 5 6 7 8 9 
          
 */

 



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

Related questions

1 answer 214 views
1 answer 234 views
1 answer 161 views
2 answers 140 views
140 views asked Oct 19, 2023 by avibootz
1 answer 100 views
1 answer 227 views
...