Doubt in display(id, name, salary) before display function

0 votes

Why is display(id, name, salary) mentioned before display function in the code provided below:

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)

    }

  }

}
Jun 19 in Apache Spark by jenny
30 views

1 answer to this question.

0 votes

The statement display(id, name, salary) is written before the display function to call the display function. If we don't write that statement, the display function will not be called and it will not be executed. Also, while calling the display function we are passing the parameters: id, name, and salary.

answered Jun 19 by Ritu

Related Questions In Apache Spark

0 votes
1 answer

How to get ID of a map task in Spark?

you can access task information using TaskContext: import org.apache.spark.TaskContext sc.parallelize(Seq[Int](), ...READ MORE

answered Nov 20, 2018 in Apache Spark by Frankie
• 9,810 points
475 views
0 votes
1 answer

Sliding function in spark

The sliding function is used when you ...READ MORE

answered Jan 29 in Apache Spark by Omkar
• 67,660 points
253 views
0 votes
1 answer

How can we iterate any function using "foreach" function in scala?

Hi, Yes, "foreach" function you use because it will ...READ MORE

answered Jul 5 in Apache Spark by Gitika
• 25,360 points
101 views
0 votes
1 answer

How do I access the Map Task ID in Spark?

You can access task information using TaskContext: import org.apache.spark.TaskContext sc.parallelize(Seq[Int](), ...READ MORE

answered Jul 23 in Apache Spark by ravikiran
• 4,560 points
53 views
0 votes
1 answer

Copy all files from local (Windows) to HDFS with Scala code

Please try the following Scala code: import org.apache.hadoop.conf.Configuration import ...READ MORE

answered May 22 in Apache Spark by Karan
403 views
0 votes
1 answer

Scala pass input data as arguments

Please refer to the below code as ...READ MORE

answered Jun 19 in Apache Spark by Lisa
46 views
0 votes
1 answer

How to calculate the result of formula with Scala?

Hi, You can use a simple mathematical calculation ...READ MORE

answered Jul 1 in Apache Spark by Gitika
• 25,360 points
51 views
0 votes
1 answer

How to execute a function in apache-scala?

Hi, Here is a simple example of how ...READ MORE

answered Jul 1 in Apache Spark by Gitika
• 25,360 points
46 views
+2 votes
4 answers

use length function in substring in spark

You can use the function expr val data ...READ MORE

answered May 3, 2018 in Apache Spark by kurt_cobain
• 9,260 points
15,669 views
0 votes
11 answers

How to create new column with function in Spark Dataframe?

val coder: (Int => String) = v ...READ MORE

answered Apr 4 in Apache Spark by anonymous

edited Apr 5 by Omkar 27,244 views