package strings;

/**
 *
 * String substring(int start)
 * String substring(int start, int end) - startindex is inclusive, endindex is exclusive
 *
 */
public class StringMethods {
    public static void main(String[] args) {

        // substring
        // startIndex is always inclusive
        // substring(int start)          -> inclusive start index till end
        // substring(int start, int end) -> inclusive start till exclusive end
        String s = "hmm";
        System.out.println(s.substring(1, 2));  // prints just 'm'
        System.out.println(s.substring(1));     // prints 'mm'
        System.out.println(s.substring(1, 3));  // prints 'mm'
        System.out.println(s.substring(1, 4));  // Runtime exception : StringIndexOutOfBoundsException

        // PS: substring on StringBuilder returns String, not StringBuilder object
    }
}

@@ -47,16 +47,21 @@
 nt start
+Index
 )%0A * Str
@@ -87,67 +87,28 @@
 tart
+Index
 , int
- end) - startindex is inclusive,
  end
-i
+I
 ndex
- is exclusive
+)
 %0A *%0A
@@ -190,29 +190,8 @@
  %7B%0A%0A
-        // substring%0A
     
@@ -230,32 +230,35 @@
 usive%0A        //
+ 1.
  substring(int s
@@ -261,17 +261,28 @@
 nt start
-)
+Index)      
         
@@ -327,16 +327,19 @@
       //
+ 2.
  substri
@@ -350,16 +350,21 @@
 nt start
+Index
 , int en
@@ -364,17 +364,23 @@
  int end
-)
+Index) 
  -%3E incl
@@ -621,32 +621,135 @@
  // prints 'mm'%0A
+        System.out.println(s.substring(2, 1));  // Runtime exception : StringIndexOutOfBoundsException%0A
         System.o

substring's end-index is exclusive