Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   




String - subString() Method


String subString(int index) & String subString(int index,int length)


subString(..) method is used to fetch a chunk of letters from a String.


Say, if we want to get the String "llo" from "Hello".


Also, we want to get the String "el" from "Hello".


Example :



public class Test{
	public static void main(String[] arg){
		String firstString = "Hello"; 
		String subStr1 = firstString.subString(2);	   
		String subStr2 = firstString.subString(1,2);	   
		
		System.out.println("The subString is : "+subStr1);
		System.out.println("The subString is : "+subStr2);
	}
}


Output :



  The subString is : llo
  The subString is : e