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 in Apache Spark by Quill
26 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 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 in Apache Spark by Raj
34 views
0 votes
1 answer

How to declare Scala array?

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

answered Jul 25 in Apache Spark by Gitika
• 25,340 points
23 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 in Apache Spark by Gitika
• 25,340 points
17 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 in Apache Spark by Gitika
• 25,340 points
21 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,240 points
5,300 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,240 points
6,672 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
4,265 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,020 points
43 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 in Apache Spark by Gitika
• 25,340 points
42 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 in Apache Spark by Gitika
• 25,340 points
40 views