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(',',' '));
}
}


运行结果
java106-字符串tocharArray,tolowercase,touppercase方法_数组