From 3034f9894966fd687c52eb313505e5c9fb71359e Mon Sep 17 00:00:00 2001 From: wandoubaba Date: Sun, 11 Aug 2024 14:40:59 +0800 Subject: [PATCH] types --- io/kotlinstudy/tour/Practice.kt | 7 +++++++ io/kotlinstudy/types/BasicTypes.kt | 18 ++++++++++++++++++ io/kotlinstudy/types/Declare.kt | 16 ++++++++++++++++ io/kotlinstudy/types/Error.kt | 7 +++++++ io/kotlinstudy/types/SpecifyType.kt | 9 +++++++++ 5 files changed, 57 insertions(+) create mode 100644 io/kotlinstudy/tour/Practice.kt create mode 100644 io/kotlinstudy/types/BasicTypes.kt create mode 100644 io/kotlinstudy/types/Declare.kt create mode 100644 io/kotlinstudy/types/Error.kt create mode 100644 io/kotlinstudy/types/SpecifyType.kt diff --git a/io/kotlinstudy/tour/Practice.kt b/io/kotlinstudy/tour/Practice.kt new file mode 100644 index 0000000..8c21ec9 --- /dev/null +++ b/io/kotlinstudy/tour/Practice.kt @@ -0,0 +1,7 @@ +package io.kotlinstudy.tour + +fun main() { + val name = "Mary" + val age = 20 + println("$name is $age years old") +} \ No newline at end of file diff --git a/io/kotlinstudy/types/BasicTypes.kt b/io/kotlinstudy/types/BasicTypes.kt new file mode 100644 index 0000000..0d8ce42 --- /dev/null +++ b/io/kotlinstudy/types/BasicTypes.kt @@ -0,0 +1,18 @@ +package io.kotlinstudy.types + +fun main() { + var customers = 10 + + customers = 8 + println("There are $customers customers") + customers = customers + 3 + println("There are $customers customers") + customers += 7 + println("There are $customers customers") + customers -= 3 + println("There are $customers customers") + customers *= 2 + println("There are $customers customers") + customers /= 3 + println("There are $customers customers") +} \ No newline at end of file diff --git a/io/kotlinstudy/types/Declare.kt b/io/kotlinstudy/types/Declare.kt new file mode 100644 index 0000000..f497358 --- /dev/null +++ b/io/kotlinstudy/types/Declare.kt @@ -0,0 +1,16 @@ +package io.kotlinstudy.types + +fun main() { + val a: Int = 1000 + println(a) + val b: String = "log message" + println(b) + val c: Double = 3.14 + println(c) + val d: Long = 100_000_000_000_000 + println(d) + val e: Boolean = false + println(e) + val f: Char = '\n' + println(f) +} \ No newline at end of file diff --git a/io/kotlinstudy/types/Error.kt b/io/kotlinstudy/types/Error.kt new file mode 100644 index 0000000..74e261a --- /dev/null +++ b/io/kotlinstudy/types/Error.kt @@ -0,0 +1,7 @@ +package io.kotlinstudy.types + +fun main() { + val d: Int +// println(d) + +} \ No newline at end of file diff --git a/io/kotlinstudy/types/SpecifyType.kt b/io/kotlinstudy/types/SpecifyType.kt new file mode 100644 index 0000000..d733066 --- /dev/null +++ b/io/kotlinstudy/types/SpecifyType.kt @@ -0,0 +1,9 @@ +package io.kotlinstudy.types + +fun main() { + val d: Int + d = 3 + val e: String = "hello" + println(d) + println(e) +} \ No newline at end of file