带有示例的 Scala String subSequence() 方法
subSequence()方法用于从给定的 String 中找到子序列,并且该子序列以我们指定的索引开始和结束。
Method Definition: CharSequence subSequence(int beginIndex, int endIndex)
Return Type: 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