字符串测试

1、字符串测试

/**
 * Created by Panda on 2018/5/15.
 */
public class Test111 {
    public static void main(String[] args) {
        String names="a|b|c";
        String[] ret=names.split("|");
        for (String s:ret) {
            System.out.print(s);  //a|b|c
        }
        System.out.println();
        System.out.println(ret.length); //5

        String[] ret1=names.split("\\|");
        for (String s1:ret1) {
            System.out.print(s1);  // abc
        }
        System.out.println();
        System.out.println(ret1.length);  //3

        String string="abcabc";
        string.replaceAll("b","a");
        System.out.println(string); //abcabc

        string=string.replace("b","a");
        System.out.println(string);//aacaac
    }
}
阅读更多

没有更多推荐了,返回首页