avatarGabriel Shanahan

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

1268

Abstract

//readmedium.com/table-of-contents-c52573cfa291">Table of Contents</a> for all articles.</p></blockquote><p id="2482">The fundamentals of classes, to which the following chapters pertain, are a topic with only a couple of larger differences between Java and Kotlin. Most of the differences are syntactical, allowing for terser code to be written. Unfortunately, even though the changes are small, we still need to go through the whole subject to cover them all. Since classes are a very broad subject indeed, this in turn means that there will be a lot of text to work through.</p><p id="d733">My expectation is that 99% of what you read will be completely intuitive, and will only require a small adjustment in how you write things. To prevent bogging you down with pointless coding exercises, they will only be included to emphasize fundamental differences between Java and Kotlin. Otherwise, only the theory is discussed.</p><p id="c5f2">Here, more than anywhere else, I recommend sort of skimming through the contents to get a general understanding of where the differences are, and come back to the material as a reference once you start writing actual code. In most cases, learning by doing is preferable to spending hours studying material you already know. Two

Options

exceptions are the lessons on <a href="https://readmedium.com/properties-introduction-fd98bc9c1056">Properties</a> and <a href="https://readmedium.com/generics-basics-51adfdca3b46">Generics</a>, which are worth dedicating some focus to.</p><p id="8bc3">The instructions above do <i>not</i> apply to the part of the Primer which follows this one, which is called “<b>Classes — What is different</b>” and starts with the chapter on <a href="https://readmedium.com/data-classes-97cbd6bfa0b7">Data Classes</a>. From that point on, almost everything will be new.</p><p id="9b40">Go back to <a href="https://readmedium.com/variable-number-of-arguments-cf08389daf96">Variable Number of Arguments</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/basic-syntax-c304635922ad">Basic Class Syntax</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>

Classes — What we know from Java

A short foreword to classes with instructions on how to read the contents

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

THE CURRENT VERSION OF THIS ARTICLE IS PUBLISHED HERE.

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

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.

The fundamentals of classes, to which the following chapters pertain, are a topic with only a couple of larger differences between Java and Kotlin. Most of the differences are syntactical, allowing for terser code to be written. Unfortunately, even though the changes are small, we still need to go through the whole subject to cover them all. Since classes are a very broad subject indeed, this in turn means that there will be a lot of text to work through.

My expectation is that 99% of what you read will be completely intuitive, and will only require a small adjustment in how you write things. To prevent bogging you down with pointless coding exercises, they will only be included to emphasize fundamental differences between Java and Kotlin. Otherwise, only the theory is discussed.

Here, more than anywhere else, I recommend sort of skimming through the contents to get a general understanding of where the differences are, and come back to the material as a reference once you start writing actual code. In most cases, learning by doing is preferable to spending hours studying material you already know. Two exceptions are the lessons on Properties and Generics, which are worth dedicating some focus to.

The instructions above do not apply to the part of the Primer which follows this one, which is called “Classes — What is different” and starts with the chapter on Data Classes. From that point on, almost everything will be new.

Go back to Variable Number of Arguments, jump to the Table of Contents, or continue to Basic Class Syntax.

Join me in Etnetera
Kotlin
Java
Programming
Class
Recommended from ReadMedium