dir.by  
Поиск >>

Компьютер, программы
→
Kotlin
 Integer numbers in Kotlin are: Byte, UByte, Short, UShort, Int, UInt, Long, ULong 
посмотрели 4417 раз
обновлено: 29 June 2026
Example: Int
  Kotlin  
val myPrice:Int = 10 // val means that CANNOT change the variable later
var myWeight:Int = 65 // var means that we can change the variable later
How much space do they take:
Type
min ... max value range
Amount of memory occupied
   Example
Byte
-128 ... 127
1 byte
  Kotlin  
var myPrice:Byte = 10
UByte
0 ... 255
1 byte
  Kotlin  
var myPrice:UByte = 10u
Short
-32768 ... 32767
2 bytes
  Kotlin  
var myPrice:Short = 10
UShort
0 ... 65535
2 bytes
  Kotlin  
var myPrice:UShort = 10u
Int
-2 147 483 648 ... 2 147 483 647
4 bytes
  Kotlin  
var myPrice:Int = 10
UInt
0 ... 4 294 967 295
4 bytes
  Kotlin  
var myPrice:UInt = 10u
Long
-9 223 372 036 854 775 808 ... 9 223 372 036 854 775 807
8 bytes
  Kotlin  
var myPrice:Long = 10
ULong
0 ... 18 446 744 073 709 551 615
8 bytes
  Kotlin  
var myPrice:ULong = 10u
 
← Previous topic
null value, use the symbol ? and ?. and !! and ?: and !!. and ?. in Kotlin
 
Next topic →
Decimal numbers in Kotlin are: Float, Double
 
Your feedback ... Comments ...
   
Your Name
Your comment (www links can only be added by a logged-in user)

Новость "Черная пятница" Dreame в Беларуси – две недели скидок до 3400 рублей
 
• What is Kotlin?
• Why is IntelliJ IDEA the most popular development environment for Kotlin?
• Download and install IntelliJ IDEA to explore Kotlin
• Create a new console project to explore Kotlin | IntelliJ IDEA
Setting the value
• Declare the variable and set the value in Kotlin | val, var, lateinit, constant: const val, global variable: companion object
null
• null value, use the symbol ? and ?. and !! and ?: and !!. and ?. in Kotlin
Int, Float, Boolean, Char ...
• Integer numbers in Kotlin are: Byte, UByte, Short, UShort, Int, UInt, Long, ULong
• Decimal numbers in Kotlin are: Float, Double
• A flag with values of true or false in Kotlin is: Boolean
• The symbol in Kotlin is: Char
• Convert number to text in Kotlin | Int → String
String
• The string, the text in Kotlin is: String
• Interpolate strings in Kotlin. Example: val address:String = "${street}, ${country}"
• What is the difference between String and StringBuilder ?
Enum
• What is an enumeration (enum) in Kotlin ?
• How do I find enum by value in Kotlin ?
Collections and Arrays
• Collections in Kotlin
• Lists in Kotlin: interface List , interface MutableList , class ArrayList. Functions to create: listOf(...), mutableListOf(...), arrayListOf(...)
• Arrays in Kotlin: class Array<T>, class IntArray, class FloatArray. Functions to create: arrayOf(...), intArrayOf(...), floatArrayOf(...)
Function
• fun() { ... } is a function in Kotlin. The function is needed to perform an action.
Extension function
• Extension function in Kotlin. Allows you to add a new function to the system (List, ..) or my (Book, ...) class
Lambda function
• Lambda function in Kotlin. Example 1: var myFunc1 : (a:Int, b:Int) -> Int = { p1, p2 -> p1 + p2 };
Class
• What is class in Kotlin? Example: class MyBook { ... } | Primary and secondary constructor | block init
• Access modifiers (private, protected, public) for a class and for methods and fields. | Kotlin
• lateinit is a late initialization for the class field | Kotlin
• class that inherits from interface in Kotlin | Example: class MyBook : IBook { ...}
• Unnamed class that inherits from interface in Kotlin | Example: val book1 = object : IBook { ...}
• Generic, template class in Kotlin | Example: class MyBook<T> { ... }
Flow
• flow is the data flow in Kotlin. These are the substitution of LiveData in Android Kotlin and the substitution of Observable in RxJava
Writing a program
• The Kotlin console app works like Android Jetpack Compose

  Ваши вопросы присылайте по почте: info@dir.by