Skip to content
Related Articles

Related Articles

Scala String subSequence() method with example
  • Last Updated : 23 Oct, 2019
GeeksforGeeks - Summer Carnival Banner

The subSequence() method is utilized to find the sub-sequence from the given String, And this sub-sequence starts and ends with the index we specify.

Method Definition: CharSequence subSequence(int beginIndex, int endIndex)

Return Type: It returns the resultant sub-sequence.

Example: 1#




// Scala program of subSequence()
// method
  
// Creating object
object GfG
  
    // Main method
    def main(args:Array[String])
    {
      
        // Applying subSequence method
        val result = "GeeksforGeeks".subSequence(5, 8)
          
        // Displays output
        println(result)
      
    }
Output:



for

Example: 2#




// Scala program of subSequence()
// method
  
// Creating object
object GfG
  
    // Main method
    def main(args:Array[String])
    {
      
        // Applying subSequence method
        val result = "GeeksforGeeks".subSequence(5, 13)
          
        // Displays output
        println(result)
      
    }
Output:
forGeeks

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :