// Parameterize arrays with types
val greetStrings = new Array[String](3)
greetStrings(0) = "Hello"
greetStrings(1) = ","
greetStrings(2) = "World!\n"
for ( i <- 0 to 2){
println ( greetStrings(i) )
}
// Scala doesn’t technically have operator overloading
// Array with initialization
val numNames = Array("zero", "one", "two")
//Scala Lists are always immutable
// LIST
val oneTwo = List(1, 2)
val threeFour = List(3, 4)
val oneTwoAndThreeFour = oneTwo ::: threeFour
println(oneTwo + " and " + threeFour + "are not mutate")
println("Thus" + oneTwoAndThreeFour + "is a new List")
// cons.” Cons prepends a new element to the beginning of an existing list
val twoThree = List(2, 3)
val oneTwoThree = 1 :: twoThree
println(oneTwoThree)
val oneTwoThree = 1 :: 2 :: 3 :: Nil
println(oneTwoThree)
// Note: Class List does offer an “append” operation
// ListBuffer, a mutable list that does offer an append operation
//Like lists, tuples are immutable, but unlike lists, tuples can contain different types of elements.
val pair = (99, "Luftballons")
println(pair._1)
println(pair._2)
Note:
-- Arrays always mutable
-- List always immutable
-- sets and maps having both mutable and immutable
//sets and maps
-- Set
-- immutable set when you using + operator, it will create new set
-- mutable set when you are using + operator it will return same set with added element