January 2017
Intermediate to advanced
420 pages
9h 25m
English
To enable classes, objects, interfaces, and functions to be used outside of the declared package we must import the required class, object, interface, or function:
import com.packt.myproject.Foo
If we have a bunch of imports from the same package, then to avoid specifying each import individually we can import the entire package at once using the * operator:
import com.packt.myproject.*
Wildcard imports are especially useful when a large number of helper functions or constants are defined at the top level, and we wish to refer to those without using the classname:
package com.packt.myproject.constants
val PI = 3.142
val E = 2.178
package com.packt.myproject
import com.packt.myproject.constants.*
fun add() = E + PI
Notice ...
Read now
Unlock full access