Inside the Friend class, make the primary constructor private and then add a secondary constructor that allows us to provide a custom name when creating an instance of the Friend class.
Computer scienceProgramming languagesKotlinObject-oriented programmingObject-oriented programming basic
Visibility modifiers for members
Private constructor
Report a typo
Write a program in Kotlin
class Friend {
private var name: String = "Alex"
// write code here
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.