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
4,767 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)

  }

}


Hope this helps!!

If you need to learn more about Scala, It's recommended to join Scala Certification course today.

Thank you!

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
662 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
• 65,770 points
759 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
• 65,770 points
651 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
• 65,770 points
747 views
0 votes
1 answer

Writing File into HDFS using spark scala

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

answered Apr 6, 2018 in Big Data Hadoop by kurt_cobain
• 9,350 points
17,371 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,350 points
29,750 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,650 points
13,804 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 21, 2018 in Blockchain by Perry
• 17,100 points
2,761 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 4, 2019 in Apache Spark by Gitika
• 65,770 points
1,629 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 4, 2019 in Apache Spark by Gitika
• 65,770 points
1,781 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