Searching...
Friday, 23 May 2014

How to Iterate a String in Java

10:29
package pretechtest;
public class StringTest {
	public static void main(String[] args) {
		String str = "Hello pretech";
		for (int i = 0; i <= str.length()-1; i++) {
			System.out.println(str.charAt(i));
		}
	}
}

Output



H
e
l
l
o
p
r
e
t
e
c
h


0 comments: