Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/main/Sample.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import scala.collection.mutable._

object Sample {
def main(args : Array[String]): Unit ={

val list : ListBuffer[Int] = ListBuffer(1,2,3,4,5,6,7,8,9,10)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use only List and try how to append a new element to it.


list += 11
println("After adding new number 11: "+list)

list -= 1
println("After removing number 1: "+list)

val evenList = list.filter(_%2 == 0)
println("Even number from list: "+evenList)

println("Displaying modified list: "+ list.map{x => x*5})

val numbers = List(1,2,3,4)
val chars = List('a', 'b', 'c', 'd')
val combinations = numbers.flatMap(n => chars.map(c => "" + c + n))
println(combinations)

}
}
Empty file removed src/main/empty
Empty file.