2021-06-13

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值