public class test45 {//将给定的字符串返回成一个数组public static char[] toArrayFromString(String target){return target.toCharArray();}//大小写转换根据所给的第二个参数取决于大小写转换public static String toLowerUpper(char[] chs,char ch){if(ch=='l'||ch=='L')return new String(chs).toLowerCase();return new String(chs).toUpperCase();}
}
测试
public class test46 {public static void main(String[] args){String target="歌谣,小白,小红,小花,小草,小黑";char[] chs={'a','f','F','d','d','F','G','R','R','u'};System.out.println(test45.toLowerUpper(chs,'l'));//替换字符System.out.println(target.replace(',',' '));}
}
运行结果