(1)最后出現(xiàn)的位置
- lastIndexOf(" ",5) 從第五位開始倒著找
String s1="asfsa dkjajd";
int last =s1.lastIndexOf("k");
System.out.println(last);```
##(2)從當(dāng)前字符串抽取子字符串
* substring()截取 ()內(nèi)表示從第幾位截(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 數(shù)字轉(zhuǎn)成字符串
String useValue = String.valueOf(1.2);
System.out.println(useValue);```
(6)替換 .replace('','')
String replace = "eeeee".replace('e','a');
System.out.println(replace);```
##(7)大小寫轉(zhuǎn)換
* toLowerCase()
* toUpperCase()
String up="djfa";
System.out.print(up.toUpperCase())```
(8)去前后空格
- trim()
(9)字符串分解
- split(" ")
[]代表一個(gè)字符串?dāng)?shù)組 可以放多個(gè)字符串
String name ="zhao,qian,usdj,fijs";
String names[]= name.split(",");
System.out.print(names);```
* ##JAVA數(shù)組
* 數(shù)組固定大小
* 類型[]+數(shù)組姓名
* =new String[5]; 新的字符串?dāng)?shù)組長度為5
* ={"a","b","c"}; 數(shù)組的字面量
* System.out.print(Arrays.toString(bArray)); 顯示數(shù)組內(nèi)容
Arrays import java.util.Arrays
##實(shí)例化字符串?dāng)?shù)組
String[] bArray = {"a","b","c"}; System.out.print(bArray[0]);```
new
String[] aArray = new String[8]; String[] cArray = new String[]{"a","c"};```
##打印數(shù)組
int[] list = {1,2,3}; System.out.print(Arrays.toString(list));```
循環(huán)打印數(shù)組
for(int k =0(初始化);k<myList.lengh(判斷條件);k++ ){
Systen.out.print(myList[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;j<dList.length ;j++ ) {
if (dList[j]>max)
max = dList[j];
}
System.out.print(max);```
___
int[] eachList = {1,2,3,4,5};
for (int abc : eachList) {
System.out.println(abc);
}```