how to substring in java

Java
String s = "Let's Get This Bread";

String subString = s.substring(6, 9);
				// (start index inclusive, end index exclusive)

// subString == "Get"// Java code to demonstrate the 
// working of substring(int begIndex) 
public class Substr1 { 
    public static void main(String args[]) 
    { 
  
        // Initializing String 
        String Str = new String("Welcome to geeksforgeeks"); 
  
        // using substring() to extract substring 
        // returns geeksforgeeks 
        System.out.print("The extracted substring is : "); 
        System.out.println(Str.substring(10)); 
    } 
} 
class scratch{
    public static void main(String[] args) {
        String hey = "Hello World";
        System.out.println( hey.substring(0, 5) );
        // prints Hello;
    }
}
Source

Also in Java: