Arrays.toString:
输出一维数组(带括号);
Arrays.deepToString:
输出二维数组(带括号);
import java.util.Arrays;
public class Main
{
public static void main(String[] args)
{
int []a= {0,12,35,11,10,8,9,352,654,2345};
int[][] b={{60,25,55,88},{78,90,99,50,22},{20,19,15,5,24}};
System.out.println(Arrays.toString(a));//输出一维数组
System.out.println(Arrays.deepToString(b));//输出二维数组
}
}
String.replace()方法:
用于替换字符串的语法:
(String).replace("目标字符串 ","要替换的字符串 ");
除replace()外,还有replaceAll(),repalceFirst()两个方法;
public class Main
{
public static void main(String[] args)
{
String str="aa,bb,aa,zz";
System.out.println(str.replace(",","#"));
System.out.println(str.replaceAll(",","#"));//替换所有出现过的该类字符串
System.out.println(str.replaceFirst(",","#"));//替换第一个出现的该类型字符串
}
}
toUpperCase()与toLowerCase()方法:
前者将所有选定的小写字母转换为大写字母;后者相反;
eg:
public class Main
{
public static void main(String[] args)
{
String str="abcdEFG";
str.toUpperCase();
System.out.println(str);
str.toLowerCase();
System.out.println(str);
System.out.println(str.toUpperCase());
System.out.println(str.toLowerCase());
}
}
输出结果:
abcdEFG
abcdEFG
ABCDEFG
abcdefg