How do we make a call to a private primary constructor in scala?
Answer Posted / Kumar Gaurav
In Scala, you cannot directly call a private primary constructor. You should create an object companion that defines the application's entry point and use it instead.nExample:n```scalanclass MyClass private(val data: Int)nobject MyClass{n def apply(data: Int): MyClass = new MyClass(data)n}nMyClass(10)n```
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers