(1)最后出现的位置
- lastIndexOf(" ",5) 从第五位开始倒着找
String s1="asfsa dkjajd";
int last =s1.lastIndexOf("k");
System.out.println(last);```
##(2)从当前字符串抽取子字符串
* substring()截取 ()内表示从第几位截(2,4)从2截到4 sub 子
String s1="ashfuyhdsahfuu".substring(2);
System.out.println(s1);```
(3)字符串拼接
- concat()
String s1="asf";
String s2="def";
String s3=s1.concat(s2);
System.out.println(s3);}```
##(4)类方法
* String.方法
##(5)valueOf 数字转成字符串
String useValue = String.valueOf(1.2);
System.out.println(useValue);```
(6)替换 .replace('','')
String replace = "eeeee".replace('e','a');
System.out.println(replace);```
##(7)大小写转换
* toLowerCase()
* toUpperCase()
String up="djfa";
System.out.print(up.toUpperCase())```
(8)去前后空格
- trim()
(9)字符串分解
- split(" ")
[]代表一个字符串数组 可以放多个字符串
String name ="zhao,qian,usdj,fijs";
String names[]= name.split(",");
System.out.print(names);```
* ##JAVA数组
* 数组固定大小
* 类型[]+数组姓名
* =new String[5]; 新的字符串数组长度为5
* ={"a","b","c"}; 数组的字面量
* System.out.print(Arrays.toString(bArray)); 显示数组内容
Arrays import java.util.Arrays
##实例化字符串数组
String[] bArray = {"a","b","c"}; System.out.print(bArray[0]);```
new
String[] aArray = new String[8]; String[] cArray = new String[]{"a","c"};```
##打印数组
int[] list = {1,2,3}; System.out.print(Arrays.toString(list));```
循环打印数组
for(int k =0(初始化);k
int total = 0;
for (int i =1;i<=100;i++){
total+=i(total=total=i);}
System.out.print(total);```
double[] dList = {1,2,9.8,100.6,87,93};
double max = dList[0];
for (int j = 1;jmax)
max = dList[j];
}
System.out.print(max);```
___
int[] eachList = {1,2,3,4,5};
for (int abc : eachList) {
System.out.println(abc);
}```