October 2018
Intermediate to advanced
370 pages
9h 15m
English
There are a couple of ways to access a package-level function. One way to do this is by using a package name with each function. This method has already been used in the previous example:
Util.hello()
The second way to access a package-level function is to import each function explicitly by using the import keyword:
import Util.hellofun main(args: Array<String>) { hello() println("Power Function") println(Util.myPow(5.0,3.0))}
Notice that by adding import Util.hello, Kotlin allows us to use the hello function without using a package name with it. The third and most common way to import a package is with the wildcard:
import Util.*fun main(args: Array<String>) { hello() println("Power Function") println(myPow(5.0,3.0)) ...Read now
Unlock full access