Skip to content

Instantly share code, notes, and snippets.

@kalaiselvan369
Created June 9, 2023 07:40
Show Gist options
  • Save kalaiselvan369/6b109a2674701772a1d509a7228d93f3 to your computer and use it in GitHub Desktop.
Save kalaiselvan369/6b109a2674701772a1d509a7228d93f3 to your computer and use it in GitHub Desktop.
Public Modifier usage
fun main() {
val recipient = User()
recipient.chat(
"Hello, ${recipient.displayName} Greetings for the day! Black Friday Sale is nearing"
)
// marketing person can only send promotion messages to the user.
// users confendential information such username, password are not visible outside the class.
}
class User {
private var userName: String? = null // not accessible outside the class
private var password: String? = null // not accessible outside the class
val displayName: String = "Joey" // accessible outside the class
private val messages = mutableListOf<String>()
private fun resetPassword() {
}
fun chat(message: String) {
messages.add(message)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment