if List(1,2,3) transforms to List.apply(1,2,3) then why new Array[String](3) does not transform to new Array[String].apply(3)?
I tried Array.apply(3) but the semantic is different from new Array[String](3).
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
When you call
new Array[String](3)you are calling the Array constructor on the Array class with a single argument: 3. Alternatively, when you callArray(3)you are calling the apply method on the Array object. In Java this is known as a static method call. It is the same as callingArray.apply(3), as you expected.