1. 程式人生 > 其它 >Oracle針對DML效能優化

Oracle針對DML效能優化

查詢字串最後一次出現的位置

//strOrig.lastIndexOf(Stringname)

Runoob 字串最後出現的位置: 19

public class SearchlastString {

public static void main(String[] args) {

String strOrig = "Hello world ,Hello Runoob";

int lastIndex = strOrig.lastIndexOf("Runoob");

  if(lastIndex == - 1)  

  {

  System.out.println("沒有找到字串 Runoob");

  }

    else

    {

      System.out.println("Runoob 字串最後出現的位置: "+ lastIndex);

    }

  }

}

字串替換

java String 類的 replace (str1,str2)

public class StringReplaceEmp{

public static void main(String args[]){

String str="Hello World";

System.out.println( str.replace( 'H','W' ) );

System.out.println( str.replaceFirst("He", "Wa") );

  System.out.println( str.replaceAll("He", "Ha") );
  }

}

Wello World
Wallo World
Hallo World