Often, classes and types need to make use of other classes and types existing outside the package in which they are declared. This can be done by importing package resources. If two classes belong in the same package, no import is necessary:
package animalsdata class Buffalo(val mass: Int, val maxSpeed: Int, var isDead: Boolean = false)
In the following code snippet, the Buffalo class does not need to be imported into the program because it exists in the same package (animals) as the Lion class:
package animalsclass Lion(val mass: Int, val maxSpeed: Int) { fun kill(animal: Buffalo) { // Buffalo type used with our import if (!animal.isDead) { println("Lion attacking animal.") animal.isDead = true println("Lion kill successful.") ...