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,600 courses taught by industry experts.

Casting in Kotlin

Casting in Kotlin

- [Instructor] Well, to avoid complicating things, rather than using the existing Kotlin class, I think we'll create a new one. Let's call this one ExploringCasting. And what I'd like to do in here is have a main method, so we just need to type in the word main and press enter, and then I want to convert my Java code into Kotlin code. Now, I'm going to copy and paste all of this in here, but every time you paste Java code into a Kotlin file, IntelliJ is going to pop up this little message saying do we want to convert the code to Kotlin? Now, I'm going to click No here, and I suggest that you should genuinely click No as well. It is much better to paste the code in and try to convert it than to rely on the IDE to convert it for you. If you do use the IDE to convert it, do take extra care to read through to check what it's done, because I wouldn't want to guarantee that it's 100% accurate, and of course you might find that there are better ways to do things than the IDE is giving you…

Contents