Latest web development tutorials

Przykłady Java - Zobacz ostatnie wystąpienie napisu

Przykłady Java Przykłady Java

Poniższe przykłady mamy funkcje łańcuchowe strOrig.lastIndexOf (stringName), aby zlokalizować położenie podciągu w strOrig stringName pojawiają się:

Przykłady kodu jest następujący:

//SearchlastString.java 文件

public class SearchlastString {
   public static void main(String[] args) {
      String strOrig = "Hello world ,Hello Reader";
      int lastIndex = strOrig.lastIndexOf("Hello");
      if(lastIndex == - 1){
         System.out.println("Hello not found");
      }else{
         System.out.println("Last occurrence of Hello
         is at index "+ lastIndex);
      }
   }
}

Wyjście jest powyższe przykłady kodu:

Last occurrence of Hello is at index 13

Przykłady Java Przykłady Java