TheBulgarianWolf

Kotlin Hello World + Data Types

Mar 5th, 2021
1,181
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fun main(args: Array<String>){
  2.     println("Hello IntelliJ!")
  3.  
  4.     //variables
  5.     val language = "French" //val cannot be changed later
  6.     var score: Int = 95 //var can be changed later
  7.     score = 15
  8.     //number types
  9.     val range: Byte = 112
  10.     println("$range")
  11.     val temperature: Short = -11245
  12.     println("$temperature")
  13.     println("$score")
  14.     val highestScore: Long = 9999
  15.     println("$highestScore")
  16.     val distance = 999.5
  17.     println("$distance")
  18.     // distance is of type Float
  19.     val distanceF = 19.5F
  20.     println("$distanceF")
  21.     var test: Number = 12.2 //casts to any number type
  22.     println("$test")
  23.     //char
  24.     val letter: Char
  25.     letter = 'k'
  26.     println("$letter")
  27.     //boolean
  28.     val flag = true
  29.     println("$flag")
  30.  
  31. }
RAW Paste Data