Please refer to the below code as per your requirement:
object example1 {
def main(args:Array[String]) {
val id = new Array[Int](5)
println("Enter id")
for (i <- 0 to 4) {
id(i) = scala.io.StdIn.readInt()
}
val name = new Array[String](5)
println("Enter name")
for (i<-0 to 4){
name(i) = scala.io.StdIn.readLine()
}
val salary = new Array[Int](5)
println("Enter salary")
for (i<-0 to 4){
salary(i)= scala.io.StdIn.readInt()
}
display(id, name, salary)
def display(id:Array[Int],name:Array[String],salary:Array[Int]) = {
id.foreach(println)
name.foreach(println)
salary.foreach(println)
}
}
}
Hope this helps!
To know more about Spark Scala, It's recommended to join Spark training online today.
Thanks!!