Skip to Content
Kotlin in Action
book

Kotlin in Action

by Svetlana Isakova, Dmitry Jemerov
February 2017
Intermediate to advanced content levelIntermediate to advanced
360 pages
11h 55m
English
Manning Publications
Content preview from Kotlin in Action

Chapter 4. Classes, objects, and interfaces

This chapter covers

  • Classes and interfaces
  • Nontrivial properties and constructors
  • Data classes
  • Class delegation
  • Using the object keyword

This chapter gives you a deeper understanding of working with classes in Kotlin. In chapter 2, you saw the basic syntax for declaring a class. You know how to declare methods and properties, use simple primary constructors (aren’t they nice?), and work with enums. But there’s more to see.

Kotlin’s classes and interfaces differ a bit from their Java counterparts: for example, interfaces can contain property declarations. Unlike in Java, Kotlin’s declarations are final and public by default. In addition, nested classes aren’t inner by default: they don’t contain ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Kotlin in Action, Second Edition

Kotlin in Action, Second Edition

Roman Elizarov, Svetlana Isakova, Sebastian Aigner
Java to Kotlin

Java to Kotlin

Duncan McGregor, Nat Pryce
Head First Kotlin

Head First Kotlin

Dawn Griffiths, David Griffiths

Publisher Resources

ISBN: 9781617293290Supplemental ContentPublisher SupportOtherPublisher WebsiteSupplemental ContentPurchase Link