dir.by  
  Search  
Programming, development, testing
Kotlin
Convert number to text in Kotlin | Int → String
  Looked at 1482 times    
 Convert number to text in Kotlin | Int → String 
last updated: 2 May 2024
Example 1. toString()
  Kotlin  
val age:Int = 45
var myText:String = age.toString()
// myText = "45"
 
Example 2. String.format("%02d", number)
The text will be made with a minimum of 2 digits
  Kotlin  
var myText:String = ""

myText = String.format("%02d", 1)
// myText = 01

myText = String.format("%02d", 7)
// myText = 07

myText = String.format("%02d", -3)
// myText = -3

myText = String.format("%02d", 15)
// myText = 15

myText = String.format("%02d", 34)
// myText = 34

myText = String.format("%02d", 179)
// myText = 179
 
← Previous topic
The symbol in Kotlin is: Char
 
Next topic →
The string, the text in Kotlin is: String
 
Your feedback ... Comments ...
   
Your Name
Your comment (www links can only be added by a logged-in user)

  Объявления  
  Объявления  
 
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 project in IntelliJ IDEA for study 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 ?
Class
What is class in Kotlin? Example: class MyBook { ... }
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> { ... }
Collections and Arrays
Create collections list, set, map and an array array in Kotlin
null
null value, use the symbol ? and ?. and !! and ?: and !!. and ?. in Kotlin
Lambda function
Lambda function in Kotlin. Example 1: var myFunc1 : (a:Int, b:Int) -> Int = { p1, p2 -> p1 + p2 };

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