java 字符串和数组

1  对字符串操作

   String f = "%05d";
   System.out.println(String.format(f, 100)); //在100的左边补0 , 总共有5位
   String str1=String.format("%-7s", "100").replaceAll(" ", "0"); //在右边补0,可以将0换成其他的字符
   System.out.println(str1);
   String str2=String.format("%7s", "100").replaceAll(" ", "0"); //在左边补0,可以将0换成其他的字符
   System.out.println(str2);

  

2  对数组操作

int []  temp =   Arrays.copyOfRange(arr, 1, arr.length);   

  

猜你喜欢

转载自www.cnblogs.com/moris5013/p/9749748.html
今日推荐