本文へスキップ
製品デスクトップツールTASTECAD図面の確認TASTEFILESファイル管理TASTEFTPファイル転送TASTESSHリモートワークスペースTASTEZIP圧縮と展開TASTEWINMファイル管理開発ツールTASTECODERust 統合開発環境TASTESTUDIO統合開発・テスト環境TASTEETLデータ統合(ETL)サーバーTASTEREMOTEリモートデスクトップサーバーTASTEGEO空間情報サーバーTASTEMAILメールワークスペース投資TASTESTOCK株式自動売買デスクトップアプリはじめるダウンロードドキュメント購入すべての製品
マーケットプレイス
ニュース
技術ニュース今日の開発ニュース開発ドキュメントプログラミング言語RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWebフロントエンド フレームワークNext.jsReactVue.js · NuxtSvelteKitAngularサーバー フレームワークSpring BootDjangoFastAPIASP.NET CoreNestJS · Expressアプリ・デスクトップ フレームワークTauriFlutterReact NativeElectronアルゴリズムアルゴリズムの基礎主要アルゴリズム発展アルゴリズム実務のアルゴリズム
コミュニティプロジェクト開発ログプロンプトAIツールの問題ショーケースコミュニティガイド
協業技術移転ウェブサイト構築デスクトップアプリ構築リリース・決済パイプライン販売パートナーお問い合わせ
サービスリモートデスクトップインストールパッケージのカスタマイズ
TASTEDEV
製品

デスクトップツール

TASTECAD複雑な図面を、軽やかにひらくTASTEFILES必要なファイルだけを、最速でTASTEFTPファイルが行き交う、いちばん端正な道TASTESSHサーバーとあなたを、より確かにつなぐTASTEZIPより速くまとめ、より安全にひらくTASTEWINM2つの画面で整理する、キーボード中心のファイルマネージャー

開発ツール

TASTECODERust アプリの編集・ビルド・デバッグ・テストまでひとつのウィンドウでTASTESTUDIO編集からリモートテスト、承認した AI 修正までTASTEETL値を見ながら、データを運ぶ

サーバー

TASTEREMOTE自社サーバーで運用するリモートデスクトップTASTEGEOGeoServer 互換の空間情報サーバーを Rust で作り直しますTASTEMAILメールの主導権を、もう一度自分の手に

投資

TASTESTOCKいつ・何を。自分で決めたルールどおりに動く株式自動売買

はじめる

ダウンロード全製品の最新版ドキュメント各製品の使い方購入サブスクリプション・永久ライセンスすべての製品全製品を一覧で
すべての製品
マーケットプレイスニュース
技術

ニュース

今日の開発ニュース言語・フレームワーク・GitHub・AI の公式発表開発ドキュメント言語・フレームワーク・アルゴリズムのガイド

プログラミング言語

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

フレームワーク

Webフロントエンド フレームワークNext.jsReactVue.js · NuxtSvelteKitAngular
サーバー フレームワークSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
アプリ・デスクトップ フレームワークTauriFlutterReact NativeElectron

アルゴリズム

アルゴリズムの基礎計算量解析 · ソート · 探索 · 基本データ構造 · 木構造とヒープ主要アルゴリズムグラフ探索 · 最短経路と最小全域木 · 動的計画法 · 貪欲法 · 分割統治法 · バックトラッキング発展アルゴリズム文字列アルゴリズム · 数学と整数論 · ビット演算 · セグメント木 · Union-Find実務のアルゴリズムコーディング面接対策 · LRUキャッシュ · レート制限 · コンシステントハッシュ法
開発ドキュメントをすべて見る
コミュニティ
プロジェクトビルダーと作品を探す開発ログ決定と試行錯誤プロンプト再利用できる指示AIツールの問題Claude・Codex・Gemini の問題と回避策ショーケース完成した成果コミュニティガイドオープンにつくる方法
協業
技術移転Rust・egui でネイティブアプリを作るウェブサイト構築10言語、アカウント、ドキュメントとダウンロードデスクトップアプリ構築Rust・egui、WebView なしリリース・決済パイプライン署名・MSI・deb・rpm・AppImage・ハッシュ販売パートナー紹介して決済額の30%お問い合わせ構築・提携・投資のご相談
サービス
リモートデスクトップブラウザから自分のパソコンへインストールパッケージのカスタマイズ必要な機能だけ、設定は事前に
購入
JA
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
ログイン
ログイン
TASTEDEV

小さなツールから、より良い開発へ。

support@tastedev.netTASTEDEVを支援
製品製品ラインナップ購入ドキュメントダウンロードマーケットプレイスサポート
コミュニティプロジェクト開発ログプロンプトAIツールの問題ショーケース
ポリシー会社概要プライバシーポリシー利用規約サブスクリプション規約返金ポリシーコミュニティガイドライン
アカウントログイン新規登録
訪問者
今日
昨日
累計閲覧
商号
GXSOFT
代表者
CHOI YOUNG GU
事業者登録番号
853-44-00368
所在地
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
電話
+82-10-4404-1523
メール
whitecalvin@tastedev.net
個人情報保護責任者
CHOI YOUNG GU

© 2026 TASTEDEV製品情報は検証済みの開発ソースに基づいています。リリース・改善中

Kotlin ドキュメント
Kotlin
Getting StartedSyntax BasicsTypes and DataModules and PackagesErrors and TestingKey Concepts
ディスカッション

Kotlin ガイド · 3/6

Types and Data

この章は現在、英語でのみ提供しています。

This chapter covers basic types, collections, and the kinds of classes Kotlin offers for modeling data.

Basic types

Numbers behave like objects with methods, yet the compiler maps them to JVM primitives wherever it can.

TypeSizeExample
Int32-bit42
Long64-bit3_000_000_000L
Double64-bit float0.75
Float32-bit float9.99f
Booleantrue or falsetrue
Charone character'K'
Stringtext"Kotlin"
fun main() {
    val count = 42               // Int
    val big = 3_000_000_000L     // Long; underscores group digits
    // val wide: Long = count    // error: no implicit widening
    val wide: Long = count.toLong()
    println(wide + big)

    println("42".toInt() + 1)    // 43
    println("abc".toIntOrNull()) // null instead of an exception
}

Unlike Java, an Int is never silently widened to a Long; convert explicitly with toLong(), toDouble() and friends.

Collections: read-only and mutable

Collection interfaces come in pairs: read-only List, Set and Map, and their MutableList, MutableSet and MutableMap counterparts. listOf gives you no add; use mutableListOf when you need to change the contents.

fun main() {
    val numbers = listOf(3, 1, 4, 1, 5)          // List<Int>
    val unique = setOf("a", "b", "a")            // Set<String>: [a, b]
    val ages = mapOf("Sam" to 31, "Ana" to 28)   // Map<String, Int>

    val todo = mutableListOf("groceries")
    todo.add("gym")
    todo.removeAt(0)

    val scores = mutableMapOf<String, Int>()
    scores["kim"] = 90
    scores["lee"] = 85

    println(numbers.filter { it > 2 }.map { it * 10 })  // [30, 40, 50]
    println(numbers.sorted().distinct())                // [1, 3, 4, 5]
    println(unique.size)                                // 2
    println(ages.getOrDefault("Max", 0))                // 0
    println(todo)                                       // [gym]
}
この章について質問がありますか?
前の章Syntax Basics次の章Modules and Packages

to is an infix function that builds a Pair. Read-only means the interface has no mutators, not that the object can never change. Expose read-only types and keep mutation inside the owning code.

Classes

The parentheses after a class name declare its primary constructor, and marking a parameter val or var turns it into a property. There is no new keyword. Classes and members are final by default, so you must mark them open to allow inheritance.

open class Animal(val name: String) {
    open fun sound(): String = "..."
    override fun toString() = "$name: ${sound()}"
}

class Dog(name: String, var age: Int) : Animal(name) {
    init {
        require(age >= 0) { "age must not be negative" }
    }

    val isPuppy: Boolean
        get() = age < 1          // computed on every read

    override fun sound() = "Woof"
}

fun main() {
    val dog = Dog("Rex", 3)
    dog.age += 1
    println(dog)          // Rex: Woof
    println(dog.isPuppy)  // false
}

init blocks run during construction, and properties can have custom getters and setters.

Data classes

For classes whose job is holding values, use data class. The compiler generates equals, hashCode, toString, copy and the componentN functions behind destructuring.

data class User(val id: Long, val name: String, val email: String? = null)

fun main() {
    val a = User(1, "Sam")
    val b = User(1, "Sam")
    println(a == b)              // true: compares property values
    println(a)                   // User(id=1, name=Sam, email=null)

    val renamed = a.copy(name = "Sammy")
    val (id, name) = renamed     // destructuring
    println("$id $name")         // 1 Sammy
}

== calls equals; use === for reference identity. The ? in String? marks a nullable type, covered in chapter 6.

Enums and sealed types

Use enum class for a fixed set of constants. When each case carries different data, use a sealed class or interface: its subtypes must live in the same module and package, so the compiler can check that a when is exhaustive.

import kotlin.math.PI

enum class Color(val hex: String) {
    RED("#FF0000"), GREEN("#00FF00"), BLUE("#0000FF");

    fun label() = name.lowercase()
}

sealed interface Shape
data class Circle(val radius: Double) : Shape
data class Rect(val width: Double, val height: Double) : Shape
data object Empty : Shape

fun area(shape: Shape): Double = when (shape) {   // no else needed
    is Circle -> PI * shape.radius * shape.radius
    is Rect -> shape.width * shape.height
    Empty -> 0.0
}

fun main() {
    println(Color.entries.map { it.label() })   // [red, green, blue]
    println(area(Rect(2.0, 3.0)))               // 6.0
}

Objects and companion objects

An object declaration defines a singleton. Kotlin has no static, so class-level factories and constants go in a companion object.

object AppConfig {
    var debug = false
    fun summary() = "debug=$debug"
}

class Temperature private constructor(val celsius: Double) {
    companion object {
        val FREEZING = Temperature(0.0)
        fun fromFahrenheit(f: Double) = Temperature((f - 32) * 5 / 9)
    }
}

fun main() {
    AppConfig.debug = true
    println(AppConfig.summary())                          // debug=true
    println(Temperature.fromFahrenheit(212.0).celsius)    // 100.0
    println(Temperature.FREEZING.celsius)                 // 0.0
}

Summary

  • Numeric types never convert implicitly; call toLong() and similar.
  • Collections split into read-only (listOf) and mutable (mutableListOf) variants.
  • Classes are final by default, and val/var constructor parameters become properties.
  • Data classes get equals, toString, copy and destructuring for free.
  • Model closed sets of cases with enum or sealed; use object for singletons and companion object instead of statics.

コメント 0件

人気のコメント順新しい順

ログイン · ログインするとコメントできます。