How to print StringBuffer using for loop in Java

1 Answer

0 votes
public class MyClass {
    public static void main(String args[]) {
        StringBuffer sb = new StringBuffer("PHP Java C++ C#"); 
 
        for (int i = 0; i < sb.length() ; i++) {
            System.out.println(sb.charAt(i));
        }
    }
}
 
 
 
/*
run:
 
P
H
P
 
J
a
v
a
 
C
+
+
 
C
#

 
*/
 

 



answered Apr 28, 2020 by avibootz

Related questions

1 answer 108 views
108 views asked Mar 15, 2023 by avibootz
1 answer 196 views
1 answer 152 views
1 answer 168 views
1 answer 163 views
163 views asked Apr 28, 2020 by avibootz
1 answer 136 views
136 views asked Sep 29, 2019 by avibootz
1 answer 209 views
...