1class Main {
2 public static void main (String[] args) {
3
4 String str = "Hello World!";
5
6 String firstWord = str.substring(0, 5);
7 //two parameters are start and end index: (inclusive, non-inclusive)
8
9 String secondWord = str.substring(6, 11);
10
11 //firstWord has string "Hello"
12 //secondWord has string "World"
13 }
14}