Skip to main content
ProductsDesktop toolsTASTECADDrawing reviewTASTEFILESFile managementTASTEFTPFile transferTASTESSHRemote workspaceTASTEZIPCompression and extractionTASTEWINMFile managementDeveloper toolsTASTECODERust integrated development environmentTASTESTUDIOIntegrated development and test environmentTASTEETLData integration (ETL)ServersTASTEREMOTERemote desktop serverTASTEGEOGeospatial serverTASTEMAILMail workspaceInvestingTASTESTOCKStock auto-trading desktop appGet startedDownloadsDocumentationBuyAll products
Marketplace
News
TechNewsToday's dev newsDeveloper docsProgramming languagesRustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWeb front-end frameworksNext.jsReactVue.js · NuxtSvelteKitAngularServer frameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · ExpressApp & desktop frameworksTauriFlutterReact NativeElectronAlgorithmsAlgorithm basicsCore algorithmsAdvanced algorithmsPractical algorithms
CommunityProjectsDevelopment logsPromptsAI tool issuesShowcaseCommunity guide
Work with usTech transferWebsite buildDesktop app buildRelease and payment pipelineSales partnerContact
ServicesRemote desktopCustom installer packages
TASTEDEV
Products

Desktop tools

TASTECADComplex drawings, opened with easeTASTEFILESJust the files you need, as fast as possibleTASTEFTPThe tidiest path for your filesTASTESSHA stronger link between you and your serversTASTEZIPPack faster, unpack saferTASTEWINMA keyboard-first file manager with two panes

Developer tools

TASTECODEEdit, build, debug and test Rust apps in one windowTASTESTUDIOFrom editing to remote tests and approved AI fixesTASTEETLMove data while you watch the values

Servers

TASTEREMOTEA remote desktop you run on your own serverTASTEGEORebuilding a GeoServer-compatible geospatial server in RustTASTEMAILTake back control of your email

Investing

TASTESTOCKStock auto-trading that follows the rules you set: when, and what

Get started

DownloadsLatest builds of every productDocsHow to use each productBuySubscriptions and perpetual licencesAll productsEvery product at a glance
All products
MarketplaceNews
Tech

News

Today's dev newsOfficial announcements on languages, frameworks, GitHub and AIDeveloper docsGuides to languages, frameworks and algorithms

Programming languages

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

Frameworks

Web front-end frameworksNext.jsReactVue.js · NuxtSvelteKitAngular
Server frameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
App & desktop frameworksTauriFlutterReact NativeElectron

Algorithms

Algorithm basicsComplexity analysis · Sorting · Searching · Basic data structures · Trees and heapsCore algorithmsGraph traversal · Shortest paths & minimum spanning trees · Dynamic programming · Greedy algorithms · Divide and conquer · BacktrackingAdvanced algorithmsString algorithms · Math and number theory · Bit manipulation · Segment trees · Union-findPractical algorithmsCoding interview strategy · LRU cache · Rate limiting · Consistent hashing
All development docs
Community
ProjectsDiscover builders and their workDevelopment logsDecisions and lessons learnedPromptsReusable instructionsAI tool issuesProblems and workarounds for Claude, Codex, GeminiShowcaseFinished resultsCommunity guideHow we build in the open
Work with us
Tech transferNative apps in Rust and eguiWebsite build10 languages, accounts, docs and downloadsDesktop app buildRust and egui, no WebViewRelease and payment pipelineSigning, MSI, deb, rpm, AppImage, hashesSales partnerRecommend us and earn 30%ContactBuilds, partnerships and investment
Services
Remote desktopReach your computer from a browserCustom installer packagesOnly the features you need, settings preloaded
Buy
EN
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
Log in
Log in
TASTEDEV

From small tools to better development.

support@tastedev.netSupport TASTEDEV
ProductsProduct lineupBuyDocsDownloadsMarketplaceSupport
CommunityProjectsDevelopment logsPromptsAI tool issuesShowcase
PoliciesAbout usPrivacy policyTerms of serviceSubscription termsRefund policyCommunity guidelines
AccountLog inSign up
Visitors
Today
Yesterday
Total views
Company
GXSOFT
Representative
CHOI YOUNG GU
Business registration number
853-44-00368
Address
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
Phone
+82-10-4404-1523
Email
whitecalvin@tastedev.net
Privacy officer
CHOI YOUNG GU

© 2026 TASTEDEVProduct information is based on verified development sources.Released · improving

Kotlin docs
Kotlin
Getting StartedSyntax BasicsTypes and DataModules and PackagesErrors and TestingKey Concepts
Discussions

Kotlin guide · 4/6

Modules and Packages

As a program grows, you split it into files and packages and pull in third-party libraries. This chapter covers packages and imports, visibility, adding dependencies with Gradle, and a short look at Kotlin Multiplatform.

Declaring a package

The package line at the top of a file sets the namespace for everything in it. Unlike Java, one file may hold several classes, and functions and properties can live at the top level, outside any class.

// src/main/kotlin/com/example/shop/Order.kt
package com.example.shop

data class Order(val id: Long, val amount: Int)

fun totalOf(orders: List<Order>): Int = orders.sumOf { it.amount }

const val FREE_SHIPPING_MIN = 50

Kotlin does not require directories to mirror package names, but the official style guide recommends it. A file without a package line belongs to the unnamed default package.

Imports

import brings in declarations from other packages: classes, but also top-level functions and properties. Resolve name clashes with an alias via as.

package com.example.app

import com.example.shop.Order
import com.example.shop.totalOf
import com.example.shop.FREE_SHIPPING_MIN
import com.example.legacy.Order as LegacyOrder
import java.time.LocalDate

fun main() {
    val orders = listOf(Order(1, 30), Order(2, 42))
    val total = totalOf(orders)
    println("${LocalDate.now()} total: $total")
    println("Free shipping: ${total >= FREE_SHIPPING_MIN}")
}

Star imports such as import com.example.shop.* also work. Several packages are imported by default, including kotlin.*, kotlin.collections.*, kotlin.text.*, kotlin.io.* and kotlin.ranges.*, plus java.lang.* on the JVM. That is why listOf and println need no import.

Visibility modifiers

ModifierTop-level declarationClass member
public (default)visible everywherevisible everywhere
internalsame modulesame module
protectednot allowedclass and subclasses
privatesame fileinside the class

Declarations are public unless you say otherwise. A module is a set of files compiled together, typically one Gradle module (strictly, one of its source sets). When writing a library, mark implementation details internal so they stay out of the public API.

Adding dependencies with Gradle

Most Kotlin libraries are published to Maven Central and identified by group:artifact:version coordinates. Current Gradle projects usually keep versions in a version catalog. Replace each x.y.z below with the version you actually want.

# gradle/libs.versions.toml
[versions]
kotlin = "x.y.z"
coroutines = "x.y.z"

[libraries]
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }

[plugins]
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
// build.gradle.kts
plugins {
    alias(libs.plugins.kotlin.jvm)
}

repositories {
    mavenCentral()
}

dependencies {
    implementation(libs.kotlinx.coroutines.core)          // from the catalog
    implementation("com.squareup.okhttp3:okhttp:x.y.z")   // raw coordinates
    testImplementation(kotlin("test"))
}

implementation is for dependencies needed to compile and run, testImplementation for test-only ones, and runtimeOnly for those needed only at run time. Browse libraries and their latest versions on Maven Central, and run ./gradlew dependencies to see the resolved dependency tree.

Multi-module builds

Larger projects are split into several Gradle modules. Register them in settings.gradle.kts, then depend on one module from another.

// settings.gradle.kts
rootProject.name = "shop"
include(":core", ":app")

// inside the dependencies block of app/build.gradle.kts:
// implementation(project(":core"))

Now internal declarations in core are invisible to app, so the compiler enforces the boundary between them.

Kotlin Multiplatform

Kotlin Multiplatform (KMP) shares code across the JVM, Android, iOS (via Kotlin/Native), the browser (Kotlin/JS and Kotlin/Wasm) and more. Shared code lives in the commonMain source set, platform code in sets such as jvmMain or iosMain. Common code declares an API with expect, and each platform supplies an actual implementation.

// commonMain
expect fun platformName(): String

fun greeting() = "Hello from ${platformName()}"

// jvmMain
actual fun platformName(): String = "JVM"

You can share only business logic and build native UIs per platform, or share the UI as well with Compose Multiplatform. When learning, start with a plain JVM project and explore KMP once you need it.

Summary

  • package sets the namespace; one file can hold many classes and top-level functions.
  • import works for classes and top-level functions alike, and as adds an alias.
  • Visibility defaults to public; internal limits a declaration to its module.
  • Add dependencies in the dependencies block of build.gradle.kts, by coordinates or through a version catalog, usually from Maven Central.
  • Kotlin Multiplatform shares code across platforms, using expect/actual for platform-specific parts.
Questions about this chapter?
Previous chapterTypes and DataNext chapterErrors and Testing

0 comments

Top commentsNewest first

Sign in · Sign in to leave a comment.