From the course: Build Spring Boot Apps with the Kotlin Programming Language
Unlock this course with a free trial
Join today to access over 22,500 courses taught by industry experts.
Project structure and packages
From the course: Build Spring Boot Apps with the Kotlin Programming Language
Project structure and packages
- [Instructor] Hello, welcome to chapter six. In this chapter we're going to be creating classes in Kotlin. Before we start doing that, I'd just like to touch on project structure. In JAVA, we structure our code as follows. We first create packages and then we build classes within those packages. From a file and folder viewpoint, the packages represent folders on our drive, and the classes are, well it's one file per class. In Kotlin, we're not quite so restricted as this. First of all, the package name doesn't need to match the folder name. Now by default the ID will create exactly the same structure as we're used to seeing in JAVA, so there's no good reason not to use the structure, but I wanted to point out that Kotlin doesn't require this strict mapping between package names and folder names. What that means is that if you've defined class two within a particular package, and you want to change the package name at the declaration at the top of that file, within Kotlin you can do…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
Project structure and packages2m 5s
-
The class declaration and class-level attributes3m 31s
-
Instantiating a class and accessing class-level attributes2m 14s
-
Creating a simple constructor5m 7s
-
Secondary constructors5m 20s
-
Alternative class design5m 3s
-
Overriding getters and setters7m 21s
-
Functions within a class2m 57s
-
Static functions3m 28s
-
Data classes7m 32s
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-