Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java check if string ends with

public class EndsWithExample{
   public static void main(String args[]){
       String str1 = new String("This is a test String");
       String str2 = new String("Test ABC");
       boolean var1 = str1.endsWith("String");
       boolean var2 = str1.endsWith("ABC");
       boolean var3 = str2.endsWith("String");
       boolean var4 = str2.endsWith("ABC");
       System.out.println("str1 ends with String: "+ var1);
       System.out.println("str1 ends with ABC: "+ var2);
       System.out.println("str2 ends with String: "+ var3);
       System.out.println("str2 ends with ABC: "+ var4);
   }
}
Source by beginnersbook.com #
 
PREVIOUS NEXT
Tagged: #java #check #string #ends
ADD COMMENT
Topic
Name
6+5 =