Skip to content

Commit 07bb0bd

Browse files
committed
prints each character of string in new line
1 parent 2487bd9 commit 07bb0bd

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package section5_Strings;
2+
3+
import java.util.Scanner;
4+
5+
public class PrintCharacterInString {
6+
7+
public static void main(String[] args) {
8+
9+
Scanner sc = new Scanner(System.in);
10+
11+
System.out.println("enter string: ");
12+
String s = sc.nextLine();
13+
printChars(s);
14+
15+
sc.close();
16+
}
17+
18+
static void printChars(String s) {
19+
for (int i = 0; i < s.length(); i++) {
20+
System.out.println(s.charAt(i));
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)