How can you use "for" statement in scala to print list from collection?

0 votes

Can anyone explain how to use "for" statement to print a list from the collection?

Jul 5, 2019 in Apache Spark by nisha

edited Jul 8, 2019 by Gitika 98 views

1 answer to this question.

0 votes

Hi,

You can use for loop in scala using this code below:

scala> for (i <- 1 to 5)println(i)

And also you can do the reverse of this by using this code:

Just you need to add by -1 in that particular code and you can see the result in a reverse manner.

answered Jul 5, 2019 by Gitika
• 50,980 points

Related Questions In Apache Spark

0 votes
1 answer

How to use uniform list in Scala?

Hey, The method List.fill() creates a list and ...READ MORE

answered Jul 31, 2019 in Apache Spark by Gitika
• 50,980 points
546 views
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,950 points
4,511 views
0 votes
1 answer

How can we use spark shell for scala without cluster?

You can run the Spark shell for ...READ MORE

answered Apr 28, 2019 in Apache Spark by Giri
128 views
+1 vote
2 answers
+1 vote
1 answer

Hadoop Mapreduce word count Program

Firstly you need to understand the concept ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,950 points
6,351 views
0 votes
1 answer

hadoop.mapred vs hadoop.mapreduce?

org.apache.hadoop.mapred is the Old API  org.apache.hadoop.mapreduce is the ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,950 points
983 views
+1 vote
11 answers

hadoop fs -put command?

put syntax: put <localSrc> <dest> copy syntax: copyF ...READ MORE

answered Dec 7, 2018 in Big Data Hadoop by Aditya
41,891 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
• 50,980 points
558 views
0 votes
1 answer

Which syntax to use to take the sum of list of collection in scala?

Hi, You can see this example to get ...READ MORE

answered Jul 5, 2019 in Apache Spark by Gitika
• 50,980 points
514 views