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 in Apache Spark by nisha

edited Jul 8 by Gitika 33 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 by Gitika
• 25,340 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 in Apache Spark by Gitika
• 25,340 points
56 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,690 points
1,365 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 in Apache Spark by Giri
59 views
0 votes
0 answers

How to create RDD from existing RDD in scala?

Can anyone suggest how to create RDD ...READ MORE

Jul 3 in Apache Spark by Nihal
17 views
0 votes
1 answer
0 votes
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,690 points
3,034 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,690 points
339 views
0 votes
10 answers

hadoop fs -put command?

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

answered Dec 7, 2018 in Big Data Hadoop by Aditya
14,980 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
54 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 in Apache Spark by Gitika
• 25,340 points
35 views