How To Append A List In Scala | Edureka Community

53219/how-to-append-a-list-in-scala

  • Home
  • Community
  • Categories
  • Apache Spark
  • How to append a list in Scala
How to append a list in Scala 0 votes Can anyone explain how can we use Scala to append to a List?
  • apache-scala
  • apache-spark
  • big-data
Jul 26, 2019 in Apache Spark by Nishant 6,904 views answer comment
  • flag

Your comment on this question:

Your name to display (optional):
Email me at this address if a comment is added after mine:
Privacy: Your email address will only be used for sending these notifications.
Add comment Cancel

1 answer to this question.

Your answer

Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Privacy: Your email address will only be used for sending these notifications.
Add answer Cancel
0 votes

Hey,

For this purpose, we use the single value ‘:+’.

scala> var a=List.empty[String] a: List[String] = List() scala> a :+="red" scala> a :+="green" scala> a :+="blue" scala> a

The output will be:

List[String] = List(red, green, blue)

Now to append a list to it:

scala> a++=List("golden","bronze") scala> a

The output will be:

List[String] = List(red, green, blue, golden, bronze)

Hope this helps!!

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

Thank you!

answered Jul 26, 2019 by Gitika 65,730 points comment
  • flag
  • ask related question

Your comment on this answer:

Your name to display (optional):
Email me at this address if a comment is added after mine:
Privacy: Your email address will only be used for sending these notifications.
Add comment Cancel

Related Questions In Apache Spark

0 votes 1 answer

How to search for a Key in a Scala Map?

Hey, The Map.contains() method will tell you if ...READ MORE

answered Jul 29, 2019 in Apache Spark by Gitika 65,730 points 1,844 views
  • apache-scala
  • apache-spark
  • big-data
0 votes 1 answer

How to format a string in Scala?

Hey, To format a string, use the .format ...READ MORE

answered Jul 31, 2019 in Apache Spark by Gitika 65,730 points 1,483 views
  • apache-scala
  • apache-spark
  • big-data
0 votes 1 answer

How to use uniform list in Scala?

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

answered Aug 1, 2019 in Apache Spark by Gitika 65,730 points 2,282 views
  • apache-scala
  • apache-spark
  • big-data
0 votes 1 answer

How to reverse a Scala list?

Hi, This reverses the order of elements in ...READ MORE

answered Aug 1, 2019 in Apache Spark by Gitika 65,730 points 2,081 views
  • apache-spark
  • big-data
  • apache-scala
+1 vote 2 answers

How do I get number of columns in each line from a delimited file??

Instead of spliting on '\n'. You should ...READ MORE

answered Aug 7, 2019 in Apache Spark by ashish 7,216 views
  • apache-spark
  • big-data
  • spark
  • spark-dataframe
  • spark-sql
  • scala
  • hadoop
+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 11,380 points 14,017 views
  • hadoop
  • big-data
  • bigdata
  • mapreduce
  • hdfs
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 11,380 points 4,831 views
  • hadoop
  • big-data
  • hdfs
  • mapreduce
+2 votes 11 answers

hadoop fs -put command?

Hi, You can create one directory in HDFS ...READ MORE

answered Mar 16, 2018 in Big Data Hadoop by nitinrawat895 11,380 points 119,056 views
  • hadoop
  • big-data
  • bigdata
  • hdfs
  • mapreduce
0 votes 2 answers

How to execute a function in apache-scala?

Function Definition : def test():Unit{ var a=10 var b=20 var c=a+b } calling ...READ MORE

answered Aug 5, 2020 in Apache Spark by Ramkumar Ramasamy 2,256 views
  • apache-scala
  • programming
  • bigdata
0 votes 1 answer

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

Hi, You can use for loop in scala using ...READ MORE

answered Jul 5, 2019 in Apache Spark by Gitika 65,730 points 1,553 views
  • apache-spark
  • big-data
  • apache-scala

Recent in Apache Spark

  • How to import pyspark in Jupyter Apr 3, 2023
  • How to import pyspark in Jupyter Notebook Apr 3, 2023
  • How to read a nested avro file format in spark dataframe Nov 16, 2022
  • How can i implement corss apply function of TSQL in pyspark May 30, 2022
  • Pyspark: Aggregate and filtering code error Apr 22, 2022
  • All categories
  • Generative AI Generative AI (1,454)
  • Power BI Power BI (1,316)
  • DevOps & Agile DevOps & Agile (4,138)
  • Data Science Data Science (100)
  • ChatGPT ChatGPT (30)
  • Cyber Security & Ethical Hacking Cyber Security & Ethical Hacking (1,057)
  • Data Analytics Data Analytics (1,266)
  • Cloud Computing Cloud Computing (4,053)
  • Machine Learning Machine Learning (337)
  • PMP PMP (1,069)
  • Python Python (3,488)
  • SalesForce SalesForce (201)
  • Selenium Selenium (1,624)
  • Software Testing Software Testing (58)
  • Tableau Tableau (608)
  • Web Development Web Development (3,972)
  • UI UX Design UI UX Design (24)
  • Java Java (1,358)
  • Azure Azure (157)
  • Database Database (858)
  • Big Data Hadoop Big Data Hadoop (1,907)
  • Blockchain Blockchain (1,673)
  • Digital Marketing Digital Marketing (121)
  • C# C# (141)
  • C++ C++ (272)
  • IoT (Internet of Things) IoT (Internet of Things) (390)
  • Kotlin Kotlin (8)
  • Linux Administration Linux Administration (389)
  • MicroStrategy MicroStrategy (7)
  • Mobile Development Mobile Development (395)
  • Others Others (2,386)
  • RPA RPA (653)
  • Talend Talend (73)
  • TypeSript TypeSript (124)
  • Apache Kafka Apache Kafka (84)
  • Apache Spark Apache Spark (596)
  • Career Counselling Career Counselling (1,091)
  • Events & Trending Topics Events & Trending Topics (28)
  • Ask us Anything! Ask us Anything! (71)

Join the world's most active Tech Community!

Welcome back to the World's most active Tech Community!

Sign up with Gmail Sign up with Facebook

OR

Password must have

At least 1 upper-case and 1 lower-case letter

Minimum 8 characters and Maximum 50 characters

SIGN UP Already have an Edureka Account? Login Forgot Password? LOGIN Don’t have edureka account? Sign Up resend ? Password must have

At least 1 upper-case and 1 lower-case letter

Minimum 8 characters and Maximum 50 characters

reset password Don’t have edureka account? Sign Up reset password Don’t have edureka account? Sign Up Send Code Don’t have edureka account? Sign Up

Subscribe to our Newsletter, and get personalized recommendations.

Google Sign up with Google facebook Signup with Facebook

Already have an account? Sign in.

webinar REGISTER FOR FREE WEBINAR X Years of Experience* Student 0-2 Years 2-5 Years 5-10 Years 10+ Years REGISTER NOW webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP "PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.

Tag » Add Element List Scala