tail()方法用于返回一个新队列,该队列由除第一个元素外的所有元素组成。
函数定义: def tail: Queue[A]
返回类型: It return a new queue that consists of all the elements except the first one.
范例1:
// Scala program of tail()
// method
// Import Queue
import scala.collection.mutable._
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Creating queues
val q1 = Queue(1, 3, 2, 7, 6, 5)
// Print the queue
println(q1)
// Applying tail method
val result = q1.tail
// Display output
print("Tail of the queue: " + result)
}
}
输出:
Queue(1, 3, 2, 7, 6, 5) Tail of the queue: Queue(3, 2, 7, 6, 5)
范例2:
// Scala program of tail()
// method
// Import Queue
import scala.collection.mutable._
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Creating queues
val q1 = Queue(5, 3, 2, 7, 6, 1)
// Print the queue
println(q1)
// Applying tail method
val result = q1.tail
// Display output
print("Tail of the queue: " + result)
}
}
输出:
Queue(5, 3, 2, 7, 6, 1) Tail of the queue: Queue(3, 2, 7, 6, 1)
相关用法
- Scala Map tail()用法及代码示例
- Scala Set tail()用法及代码示例
- Scala SortedSet tail()用法及代码示例
- Scala Stack tail()用法及代码示例
- Scala SortedMap tail()用法及代码示例
- Scala TreeSet tail()用法及代码示例
- Scala Queue ++=()用法及代码示例
- Scala Queue :+()用法及代码示例
- Scala Queue sum()用法及代码示例
- Scala Queue +=:()用法及代码示例
- Scala Queue ++()用法及代码示例
- Scala Queue ++:()用法及代码示例
- Scala Queue +:()用法及代码示例
- Scala Queue +=()用法及代码示例
- Scala Queue contains()用法及代码示例
注:本文由纯净天空筛选整理自rupesh_rao大神的英文原创作品 Scala Queue tail() method with example。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。