List and ListBuffer in Scala

Hey there!

Welcome to ClearUrDoubt.com.

In this post, we will look at a program to demonstrate List and ListBuffer objects in Scala.

  1.  List is an immutable collection object whereas ListBuffer is a mutable collection object.
  2. List provides a way to add an element only in the beginning(using “::” (cons) operator) where as ListBuffer will enable us to add an element at the beginning(using “+=:” operator) and ending(using “+=” operator.

Let’s look at the program:

Happy Learning.

Please leave a reply in case of any queries.

Output:

Happy Learning.

Please leave a reply in case of any queries.

Leave a Reply

Your email address will not be published.