Scala: Add user input to array

0 votes
Hey. Can someone tell me what code to use to add user input into array using Scala?
Jun 19, 2019 in Apache Spark by Quill
311 views

1 answer to this question.

0 votes

You can try this: 

object printarray {

  def main(args:Array[String]) {

    val arr = new Array[Int](3)


    println("the values of array is ")

    for (i <- 0 to 2) {

      arr(i) = scala.io.StdIn.readInt()

    }


    arr.foreach(println)

  }

}
answered Jun 19, 2019 by Dinesha

Related Questions In Apache Spark

0 votes
1 answer

How to add modify access for Web UI user?

For a user to have modification access ...READ MORE

answered Mar 14, 2019 in Apache Spark by Raj
67 views
0 votes
1 answer

How to declare Scala array?

Hi, We can declare Scala arrays in two ...READ MORE

answered Jul 25, 2019 in Apache Spark by Gitika
• 31,310 points
68 views
0 votes
1 answer

How to process an Array in Scala?

Hi, We can use loop control structures to ...READ MORE

answered Jul 25, 2019 in Apache Spark by Gitika
• 31,310 points
47 views
0 votes
1 answer

How to create Scala Array with Range?

Hey, The range() method will give us integers ...READ MORE

answered Jul 25, 2019 in Apache Spark by Gitika
• 31,310 points
60 views
0 votes
1 answer

Writing File into HDFS using spark scala

The reason you are not able to ...READ MORE

answered Apr 5, 2018 in Big Data Hadoop by kurt_cobain
• 9,310 points
9,890 views
0 votes
1 answer

How to groupBy/count then filter on count in Scala

I think the exception is caused because ...READ MORE

answered Apr 19, 2018 in Big Data Hadoop by kurt_cobain
• 9,310 points
16,802 views
0 votes
1 answer

Changing Column position in spark dataframe

Yes, you can reorder the dataframe elements. You need ...READ MORE

answered Apr 19, 2018 in Apache Spark by Ashish
• 2,630 points
7,718 views
+1 vote
1 answer

Which data structure to prefer to model a blockchain?

To start with, let me tell you ...READ MORE

answered Apr 20, 2018 in Blockchain by Perry
• 17,090 points
109 views
0 votes
1 answer

How to create RDD from parallelized collection in scala?

Hi, You can check this example in your ...READ MORE

answered Jul 3, 2019 in Apache Spark by Gitika
• 31,310 points
341 views
0 votes
1 answer

How to create RDD from an external file source in scala?

Hi, To create an RDD from external file ...READ MORE

answered Jul 3, 2019 in Apache Spark by Gitika
• 31,310 points
287 views