Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6923577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:33:11+00:00 2026-05-27T10:33:11+00:00

In Programming in scala it is stated that lists are immutable and arrays are

  • 0

In “Programming in scala” it is stated that lists are immutable and arrays are mutable. But I can’t change the array length — neither can I with list, so in this way they are both immutable. I can change array’s element value — just setting a new one, and I can modify a list’s element value with, say, map method. So in this way they are both mutable.

So why arrays are considered to be mutable and lists not?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:33:12+00:00Added an answer on May 27, 2026 at 10:33 am

    First, it’s important to know that Scala actually has both mutable and immutable collections. If you use scala.collection.mutable.ListBuffer, it will (as the name indicates) be mutable. If you use scala.collection.immutable.List it will not be.

    Second, the map function does not alter the elements of the list, rather, it creates an entirely new list containing the result of the map function applied to each element of the start list, for example:

    var l1 = List(1,3,5)
    var l2 = l1.map( _ + 2 )
    println(l1) // List(1, 3, 5)
    println(l2) // List(2, 4, 6)
    

    l2 now contains a new list, entirely separate from l1, and l1 has not been changed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From reading parts of the Programming in Scala book, I realize that Scala can
I don't understand why authors said that Code Listing 9.1 from Programming in Scala
Warning: I'm cross-posting from #scala The book Programming in Scala states that path-dependent types
Programming In Scala explains that tuples' _N numbers are one-based, instead of zero-based, because
I read in Programming in Scala section 23.5 that map, flatMap and filter operations
In 'Programming in Scala, Second Edition' at page 410 you can find class Simulation
I am currently studding Scala 2.8 using Programming in Scala 2nd edition. But I
In Programming in Scala the authors write that Scala's == function compares value equality
I've been programming in Scala for a while and I like it but one
Programming Student here...trying to work on a project but I'm stuck. The project is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.