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.

Variable declaration syntax

Variable declaration syntax

- [Instructor] Okay, so that's enough to get us started. I know that this isn't a very Kotlin like code and we'll be improving on that a little later on. But for now, I'm just going to remove this so we've got an empty function to play with. Ready to start exploring some Kotlin code. Now I did say I'm going to be typing some Java in as well. You don't need to do this, but so that I can do that, I'm going to create a clause in my Java package and I'm going to call this BoringJava code. And let's just create a main method in here as well. Well, I promised you then we would be learning about strings in this chapter, so let's get started. And we will know how to declare a string in Java. You do the object type first, then the name of your variable, and then you set it equal to something, optionally with a semi colon on the end. So let's have a look at this line of code in Kotlin. Well, it's a bit different. First of all, you must start your variable declaration with the keyword, var…

Contents