How to print queue in Scala

1 Answer

0 votes
import scala.collection.mutable._

object O {
    def main(args: Array[String]): Unit = {
        val q = Queue(6, 8, 0, 1, 4)  

        println(q) 
        
        q.foreach((element:Int) => printf("%3d", element))  
    }
}
     
     
     
     
/*
run:
     
Queue(6, 8, 0, 1, 4)
  6  8  0  1  4

*/

 



answered Oct 16, 2020 by avibootz
...