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, 2019 in Apache Spark by jenny
405 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, 2019 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,830 points
3,097 views
0 votes
1 answer

Sliding function in spark

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

answered Jan 29, 2019 in Apache Spark by Omkar
• 69,210 points
2,473 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, 2019 in Apache Spark by Gitika
• 65,910 points
1,372 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, 2019 in Apache Spark by ravikiran
• 4,620 points
1,241 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, 2019 in Apache Spark by Karan
3,763 views
0 votes
1 answer

Scala pass input data as arguments

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

answered Jun 19, 2019 in Apache Spark by Lisa
2,133 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, 2019 in Apache Spark by Gitika
• 65,910 points
1,015 views
0 votes
2 answers

How to execute a function in apache-scala?

Function Definition : def test():Unit{ var a=10 var b=20 var c=a+b } calling ...READ MORE

answered Aug 5, 2020 in Apache Spark by Ramkumar Ramasamy
685 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,390 points
41,975 views
+2 votes
14 answers

How to create new column with function in Spark Dataframe?

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

answered Apr 5, 2019 in Apache Spark by anonymous

edited Apr 5, 2019 by Omkar 87,600 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP