Answers for "string in java ending in a subtring"

9

how to substring in java

class scratch{
    public static void main(String[] args) {
        String hey = "Hello World";
        System.out.println( hey.substring(0, 5) );
        // prints Hello;
    }
}
Posted by: Guest on January-08-2020
0

how to check the end of a string java

public class Demo {
    public static void main(String[] args) {
       String str = "demo";
       if(str.endsWith("mo")) {
          System.out.println("The string ends with the word mo");
       } else {
          System.out.println("The string does not end with the word mo");
       }
    }
}
Posted by: Guest on July-04-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language