Scala Programming List - Exercises, Practice, Solution
Scala Programming List [24 exercises with solution]
[An editor is available at the bottom of the page to write and execute the scripts. Go to the editor]
1. Write a Scala program to create a list in different ways.
Note: Use Lisp style, Java style, Range list, Uniform list, Tabulate list
Click me to see the sample solution
2. Write a Scala program to add single element and multiple elements to a given listbuffer/list.
Click me to see the sample solution
3. Write a Scala program to remove single and multiple elements from a given listbuffer/list.
Click me to see the sample solution
4. Write a Scala program to delete element(s) from a given List.
Click me to see the sample solution
5. Write a Scala program to iterate over a list to print the elements and calculate the sum and product of all elements of this list.
Click me to see the sample solution
6. Write a Scala program to find the largest and smallest number from a given list.
Click me to see the sample solution
7. Write a Scala program to remove duplicates from a given list.
Click me to see the sample solution
8. Write a Scala program to check a given list is empty or not.
Click me to see the sample solution
9. Write a Scala program to get the difference between two given lists.
Click me to see the sample solution
10. Write a Scala program to find the first and last element of given list.
Click me to see the sample solution
11. Write a Scala program to find the index of an element in a given list.
Click me to see the sample solution
12. Write a Scala program to merge (concatenate) given lists.
Click me to see the sample solution
13. Write a Scala program to find the even and odd numbers from a given list.
Click me to see the sample solution
14. Write a Scala program to find the nth element of a given list.
Click me to see the sample solution
15. Write a Scala program to find an element from the last position of a given list.
Click me to see the sample solution
16. Write a Scala program to reverse a given list.
Click me to see the sample solution
17. Write a Scala program to check a given list is a palindrome or not.
Click me to see the sample solution
18. Write a Scala program to flatten a given List of Lists, nested list structure.
Click me to see the sample solution
19. Write a Scala program to triplicate each element immediately next to the given list of integers.
Click me to see the sample solution
20. Write a Scala program to add each element n times to a given list of integers.
Click me to see the sample solution
21. Write a Scala program to check whether a list contains a sublist.
Click me to see the sample solution
22. Write a Scala program to count the number of occurrences of each element in a given list.
Click me to see the sample solution
23. Write a Scala program to split a given list into two lists.
Click me to see the sample solution
24. Write a Scala program to calculate the length of a given list.
Click me to see the sample solution
More...
Scala Code Editor:
More to Come !
Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.
Test your Python skills with w3resource's quiz
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/scala-exercises/list/index.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics