当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Scala String subSequence()用法及代码示例


利用subSequence()方法从给定的字符串中查找sub-sequence,并且此sub-sequence以指定的索引开头和结尾。

函数定义: CharSequence subSequence(int beginIndex, int endIndex)

返回类型: It returns the resultant sub-sequence.



示例: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


相关用法


注:本文由纯净天空筛选整理自nidhi1352singh大神的英文原创作品 Scala String subSequence() method with example。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。