Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Example on: Getting the substring after the first occurrence of a separator in Java

public class Demo {
   public static void main(String[] args) {
      String str = "Tom-Hanks";
      String separator ="-";
      int sepPos = str.indexOf(separator);
      if (sepPos == -1) {
         System.out.println("");
      }
      System.out.println("Substring after separator = "+str.substring(sepPos +       separator.length()));
   }
}
Source by www.tutorialspoint.com #
 
PREVIOUS NEXT
Tagged: #Example #Getting #substring #occurrence #separator #Java
ADD COMMENT
Topic
Name
1+9 =