📌  相关文章
📜  带有示例的 Scala String subSequence() 方法

📅  最后修改于: 2022-05-13 01:54:24.998000             🧑  作者: Mango

带有示例的 Scala String subSequence() 方法

subSequence()方法用于从给定的 String 中找到子序列,并且该子序列以我们指定的索引开始和结束。

示例: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)
      
    }
} 
输出:
for

示例: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)
      
    }
} 
输出:
forGeeks