From the course: Android Studio Essential Training 2020

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Create new Kotlin and Java code files

Create new Kotlin and Java code files

From the course: Android Studio Essential Training 2020

Start my 1-month free trial

Create new Kotlin and Java code files

- [Instructor] Android Studio makes it easy to add new Java and Kotlin code files to your project. Assuming you've created a project that already uses Kotlin, you can create a new Kotlin file or class by going to a package, right clicking, choosing New, and then Kotlin File/Class. You need to choose the kind of file that you want to create. If you use the default of file, you'll be creating a top level file where you can create functions that are available to the entire app. Or, you can create a class, and then just like Java, you're creating a class structure. I'll create a class named StringUtility. If your project is already integrated with Git, you'll be prompted to add the file to Git. And then you can start creating functions in the class. So, for example, I might create a function named getAString. And then I might set the return type as String. And then I'll have a return statement that says, "here's a…

Contents