Update from Forestry.io

Harsh Shandilya updated content/posts/teachingkotlin-part-1-classes-and-objects-and-everything-in-between.md
This commit is contained in:
Harsh Shandilya 2019-09-20 20:24:45 +00:00 committed by Forestry.io
parent 5d2e7e3fef
commit 043f7463ba
1 changed files with 25 additions and 0 deletions

View File

@ -7,3 +7,28 @@ tags = ["android", "teachingkotlin", "kotlin"]
title = "#TeachingKotlin Part 1 - Classes and Objects and everything in between"
+++
Classes in Kotlin closely mimic their Java counterparts in implementation, with some crucial changes that I will attempt to outline here.
Let's declare two identical classes in Kotlin and Java as a starting point. We'll be making changes to them alongside to show how different patterns are implemented in the two languages.
\`\`\`java
class Example {
private final String name;
Example(String name) {
this.name = name;
}
}
\`\`\`
\`\`\`kotlin
class Example(val name: String)
\`\`\`