avatarGabriel Shanahan

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

1092

Abstract

mp;utm_term=KotlinPrimer">Etnetera a.s.</a> and I would like to express my sincere gratitude for their support.</p></blockquote><blockquote id="757e"><p>It is recommended to read the <a href="https://readmedium.com/introduction-2cc7eba631e2">Introduction</a> before moving on. Check out the <a href="https://readmedium.com/table-of-contents-c52573cfa291">Table of Contents</a> for all articles.</p></blockquote><p id="2482">Classes in Kotlin reflect their counterparts in Java to a certain degree, but are designed with brevity in mind, and the way they are written differs in certain aspects. On top of that, Kotlin adds a couple of features that are not available in Java, which makes classes in Kotlin more powerful than their Java counterparts.</p><p id="25d2">But we’ll get to that. For now, let’s start with the basics.</p> <figure id="028e"> <div> <div> <img class="ratio" src="http://placehold.it/16x9"> <iframe class="" src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fpl.kotl.in%2F0Kjtu4NCU%3Ffrom%3

Options

D2%26to%3D27&display_name=Kotlin+Playground&url=https%3A%2F%2Fpl.kotl.in%2F0Kjtu4NCU%3Ffrom%3D2%26to%3D27&image=https%3A%2F%2Fplay.kotlinlang.org%2Fassets%2Fog-image.png&key=a19fcc184b9711e1b4764040d3dc5c07&type=text%2Fhtml&schema=kotl" allowfullscreen="" frameborder="0" height="300" width="800"> </div> </div> </figure></iframe></div></div></figure><p id="c168">Go back to <a href="https://readmedium.com/classes-what-we-know-from-java-9204d5b61732">Foreword</a>, jump to the <a href="https://readmedium.com/table-of-contents-c52573cfa291">Table of Contents</a>, or continue to <a href="https://readmedium.com/constructors-b257b860be8f">Constructors</a>.</p><figure id="8ecd"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*biBSB579iezsNvEQ_NMLBg.png"><figcaption><a href="https://www.etnetera.cz/prace-u-nas?utm_source=medium&amp;utm_medium=GabrielShanahan&amp;utm_campaign=KotlinPrimer&amp;utm_content=join-our-team&amp;utm_term=KotlinPrimer#pozice">Join me in Etnetera</a></figcaption></figure></article></body>

Basic Class Syntax

Basic syntax of classes in Kotlin, treating the constructor as a function, and empty class bodies

— — — — — — — — — — — — — — —

THE CURRENT VERSION OF THIS ARTICLE IS PUBLISHED HERE.

— — — — — — — — — — — — — — —

Tags: #FYI

This article is part of the Kotlin Primer, an opinionated guide to the Kotlin language, which is indented to help facilitate Kotlin adoption inside Java-centric organizations. It was originally written as an organizational learning resource for Etnetera a.s. and I would like to express my sincere gratitude for their support.

It is recommended to read the Introduction before moving on. Check out the Table of Contents for all articles.

Classes in Kotlin reflect their counterparts in Java to a certain degree, but are designed with brevity in mind, and the way they are written differs in certain aspects. On top of that, Kotlin adds a couple of features that are not available in Java, which makes classes in Kotlin more powerful than their Java counterparts.

But we’ll get to that. For now, let’s start with the basics.

Go back to Foreword, jump to the Table of Contents, or continue to Constructors.

Join me in Etnetera
Kotlin
Java
Programming
Class
Constructor
Recommended from ReadMedium