String StringBuffer Arrays 字符串修改 拼接

package Baozhuang;

import java.util.Arrays;
import java.util.Scanner;

public class exe {
    public static void main(String[] args) {
        String s = "27O51I51022I8";
        s = s.replace('O', '0');
        s = s.replace('I', '1');
        System.out.println(s);
        
        String s0 = "MY_English_NaMe";
        String[] s1 = s0.split("_");
        s1[0] = s1[0].toLowerCase();
        s1[1] = s1[1].toUpperCase();
        s1[2] = s1[2].toUpperCase();
        //String 拼接
        String s2 =s1[0]+ s1[1]+s1[2];
        String s3 = s1[0].concat(s1[1]).concat(s1[2]);
        System.out.println(s3);
        System.out.println(s2);
        System.out.println(Arrays.toString(s1));
        //StringBuffer拼接
        StringBuffer s4 = new StringBuffer(s1[0]);
        s4 =  s4.append(s1[1]).append(s1[2]);
        System.out.println(s4);
        
        Scanner input = new Scanner(System.in);
        String word;
        StringBuffer s5 = new StringBuffer();
        do{
            System.out.println("请输入英文单词:");
            word = input.nextLine();
            if (word.equals("end")){
                break;
            }
            s5 = s5.append(word+",");
        }while(true);
        System.out.println(s5);
        String s6 = s5.toString();
        String [] s7 = s6.split(",");
        /*for(int i = 0; i < s7.length ; i++){
            System.out.println(s7[i]);
        }*/
        //for each循环
        for (String s8:s7){
            System.out.println(s8);
        }
        input.close();
    }
}

 

posted @ 2016-08-11 16:45  me丶不是好人  阅读(297)  评论(0编辑  收藏  举报