diff --git a/.forestry/front_matter/templates/blog-post.yml b/.forestry/front_matter/templates/blog-post.yml index db3fd69..d44122a 100644 --- a/.forestry/front_matter/templates/blog-post.yml +++ b/.forestry/front_matter/templates/blog-post.yml @@ -18,7 +18,7 @@ fields: name: categories label: categories pages: -- content/posts/teachingkotlin-kotlin-for-android-java-developers.md - content/posts/teachingkotlin-part-1-classes-and-objects-and-everything-in-between.md +- content/posts/teachingkotlin-kotlin-for-android-java-developers.md - content/posts/teachingkotlin-part-2-variables.md - content/posts/why-i-went-back-to-the-gradle-groovy-dsl.md diff --git a/content/posts/teachingkotlin-part-1-classes-and-objects-and-everything-in-between.md b/content/posts/teachingkotlin-part-1-classes-and-objects-and-everything-in-between.md index 8f4972a..00ef256 100644 --- a/content/posts/teachingkotlin-part-1-classes-and-objects-and-everything-in-between.md +++ b/content/posts/teachingkotlin-part-1-classes-and-objects-and-everything-in-between.md @@ -1,10 +1,11 @@ +++ categories = ["kotlin", "dev", "android", "teachingkotlin"] -date = "2019-09-23T15:00:00+05:30" +date = 2019-09-23T09:30:00Z +description = "Part 1 of my #TeachingKotlin, this post goes over Kotlin classes, objects and how things like finality and staticity vary between Java and Kotlin." slug = "teaching-kotlin--classes-and-objects" tags = ["android", "teachingkotlin", "kotlin"] title = "#TeachingKotlin Part 1 - Classes and Objects and everything in between" -description = "Part 1 of my #TeachingKotlin, this post goes over Kotlin classes, objects and how things like finality and staticity vary between Java and Kotlin." + +++ Classes in Kotlin closely mimic their Java counterparts in implementation, with some crucial changes that I will attempt to outline here. @@ -12,7 +13,7 @@ Let's declare two identical classes in Kotlin and Java as a starting point. We'l Java: -```java +{{< highlight java >}} class Person { private final String name; @@ -20,13 +21,13 @@ class Person { this.name = name; } } -``` +{{< /highlight >}} Kotlin: -```kotlin +{{< highlight kotlin >}} class Person(val name: String) -``` +{{< /highlight >}} The benefits of using Kotlin immediately start showing! But let's go over this in a sysmetatic fashion and break down each aspect of what makes Kotlin so great.