Java遍历字符串

Java遍历字符串

贴代码:

package helloworld;

import org.junit.Test;

/**
 * Created with IntelliJ IDEA.
 * User: ASUS
 * Date: 14-9-11
 * Time: 上午1:19
 * To change this template use File | Settings | File Templates.
 */
public class TestString {

    @Test
    public void test789() {
        String s1 = "qwertyuo";
        for (int i = 0; i < s1.length(); i++) {
            char ch = s1.charAt(i);
            System.out.println(ch);
        }
    }

    @Test
    public void test79() {
        String s1 = "qwertyuo";
        char[] s2 = s1.toCharArray();
        for (char c : s2) {
            System.out.println(c);
        }
    }
}


====END====


你可能感兴趣的:(Java遍历字符串)