?? strconverttest.java.bak
字號:
public class StrConvertTest{
String sourceStr1 = " There is an example about action of String";
String sourceStr2 = "13665127089";
String sourceStr3;
public static void main(String args[]){
String tempStr1,tempStr2,tempStr3;
StringBuffer strBuf1;
boolean boolVar1,boolVar2,boolVar3,boolVar4,boolVar5,boolVar6,boolVar7;
int intVar1,intVar2,intVar3;
Integer intObj;
StrConvertTest classObj = new StrConvertTest();
System.out.println("Source string 1:"+classObj.sourceStr1);
System.out.println("Source string 2:"+classObj.sourceStr2);
classObj.setStr("13681235647");
System.out.println("Source string 3:"+classObj.sourceStr3);
tempStr1 = classObj.sourceStr2;
tempStr2 = classObj.sourceStr3;
boolVar1 = tempStr1.startsWith("1366");
System.out.println("Does source string 2 start with 1366?"+boolVar1);
boolVar2 = tempStr1.startsWith("66",2);
System.out.println("Does source string 2 start with 66 from index 2?"+boolVar2);
boolVar3 = tempStr1.endsWith("89");
System.out.println("Does source string 2 end with 89?"+boolVar3);
boolVar4 = tempStr1.equals(tempStr2);
System.out.println("Does source string 2 equal to source string 3?"+boolVar4);
intVar1 = tempStr1.compareTo(tempStr2);
System.out.println("Result of '13665127089' compare to '13681235647'"+intVar1);
boolVar5 = tempStr1.regionMatches(false,3,"1366",0,4);
System.out.println("Does source string 2 match with 1366 from index 3 ignoring case?"+boolVar5);
boolVar6 = tempStr1.regionMatches(3,"1366",0,4);
System.out.println("Does source string 2 match with 1366 from index 3?"+boolVar6);
strBuf1 = new StringBuffer(tempStr1);
strBuf1.setCharAt(3,'7');
System.out.println("After setting '7' at index 3 of '13665127089':"+strBuf1);
strBuf1.insert(3,'5');
System.out.println("After inserting '5' at index 3:"+strBuf1);
strBuf1.deleteCharAt(3);
System.out.println("After deleting '5' at index 3:"+strBuf1);
strBuf1.replace(0,3,"135");
System.out.println("After replacing sub string from 0 to 3:");
intObj = Integer.valueOf("1367");
intVar2 = intObj.intValue();
System.out.println("After invert string to int:"+intVar2);
intVar2 = intVar2 +3;
tempStr3 = Integer.toString(intVar2);
System.out.println("After invert int to string:"+tempStr3);
}
void setStr(String str){
sourceStr3 = str;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -