Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,152 questions

40,706 answers

573 users

How to print list in Scala

3 Answers

0 votes
object O {
    def main(args: Array[String]): Unit = {
        val lst = List("scala", "c", "c++", "java")
        
        print(lst)
        
        println()
 
        lst.foreach(println(_))
    }
}
  
   
   
   
/*
run:
   
List(scala, c, c++, java)
scala
c
c++
java
   
*/

 





answered Sep 7, 2020 by avibootz
edited Sep 7, 2020 by avibootz
0 votes
object O {
    def main(args: Array[String]): Unit = {
        val lst = List("scala", "c", "c++", "java")
 
        for(s<-lst) {  
            println(s)  
        }  
    }
}
  
   
   
   
/*
run:
   
scala
c
c++
java
   
*/

 





answered Sep 7, 2020 by avibootz
0 votes
object O {
    def main(args: Array[String]): Unit = {
        val lst = List("scala", "c", "c++", "swift", "java")

        for (i <- 0.until(lst.length)) {
            println(lst(i))
        }
    }
}
     
     
     
     
/*
run:
     
scala
c
c++
swift
java
    
*/

 





answered Oct 16, 2020 by avibootz

Related questions

1 answer 54 views
54 views asked Jun 1, 2021 by avibootz
1 answer 120 views
1 answer 55 views
1 answer 46 views
46 views asked Jun 1, 2021 by avibootz
1 answer 53 views
...