E-Book, Englisch, 420 Seiten
Samuel / Bocutiu Programming Kotlin
1. Auflage 2025
ISBN: 978-1-78712-265-9
Verlag: De Gruyter
Format: PDF
Kopierschutz: Adobe DRM (»Systemvoraussetzungen)
Get to grips quickly with the best Java alternative
E-Book, Englisch, 420 Seiten
ISBN: 978-1-78712-265-9
Verlag: De Gruyter
Format: PDF
Kopierschutz: Adobe DRM (»Systemvoraussetzungen)
Quickly learn the fundamentals of the Kotlin language and see it in action on the web. Easy to follow and covering the full set of programming features, this book will get you fluent in Kotlin for Android.
Autoren/Hrsg.
Fachgebiete
Weitere Infos & Material
Mixing Kotlin and Java in a project
Using different languages within the same project is quite common; I came across projects where a mix of Java and Scala files formed the code base. Could we do the same with Kotlin? Absolutely. Let's work on the project created earlier, . You should see the following directory structure in your IntelliJ (the standard template for a Java/Kotlin project):
Project layout
You can place Java code within the folder. Add a new package to the folder with the same name as the one present in the folder: . Create a New | Java class named and use this code for the purpose of the exercise:
public class CarManufacturer { private final String name; public CarManufacturer(String name) { this.name = name; } public String getName() { return name; } }What if you want to add a Java class under the subfolder? Let's create a class similar to the previous one and provide a field name for simplicity:
public class Student { private final String name; public Student(String name) { this.name = name; } public String getName() { return name; } }In the function, let's instantiate our classes:
fun main(args: Array



