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
19 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
27 views
0 votes
1 answer
0 votes
1 answer

How to add third party java jars for use in PySpark?

You can add external jars as arguments ...READ MORE

answered Jul 4, 2018 in Apache Spark by nitinrawat895
• 10,110 points
987 views
0 votes
1 answer

Multidimensional Array in Scala

Multidimensional array is an array which store ...READ MORE

answered Feb 11 in Apache Spark by Omkar
• 67,120 points
65 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
4,359 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
5,109 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
3,432 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,010 points
32 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
• 19,720 points
22 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
• 19,720 points
20 views