Even when using Kotlin there may be times when you need to work with an existing Java class. You can still take advantage of your extension functions in this scenario. Learn how in this video.
Even when using Kotlin, there may be times…when you need to work with an existing Java class.…But we can still take advantage of our…extension functions in that scenario as well.…Here in our planet class, we have our extension…property for getting the composition.…Let's create a scratch file to test out…how we could use this from a Java class.…So we'll do that with the command shift n shortcut.…And our file is going to be of type Java.…So just like before, we're in…a standard Java class and we're going to…create a new class that we call sample use.…
And we'll create a simple method in here…of public void use extension.…And this is where we're going to put the code…in order to test out our Kotlin…extension property that we created.…So first we're going to need a planet.…Let's just name it p.…So we'll create a new one here in line six.…And now let's try to call the planets composition method.…Oh, but look, we don't get anything.…Why is that?…Well, the compiler doesn't know anything…about this symbol, composition.…
- What Kotlin has to offer
- Working with lambdas
- Common Android extension functions
- Kotlin Android Extensions overview
- Making use of the Anko library
- Working with coroutines
- Nullability and collections
Skill Level Intermediate
Android App Development: Data Persistence Librarieswith Annyce Davis3h 59m Intermediate
Developing AWS Lambda Functions with Kotlinwith Troy Miles1h 55m Intermediate
1. Kotlin Overview
2. Extension Functions and Properties
3. Incorporating Anko
4. Advanced Anko
5. Working with Collections
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.