Kotlin - Statement Packages

Introduction

Packages allow us to split code into namespaces.

Any Kotlin file may begin with a package declaration:

package com.java2s.myproject 

class Foo 

fun bar(): String = "bar" 

The package name is used to give us the fully qualified name for a class, object, interface, or function.

Here, the class Foo has the fully qualified name com.java2s.myproject.Foo.

The top level function bar has the fully qualified name of com.java2s.myproject.bar.