fork download
  1. val topData1: Int = 1//error
  2. var topData2: Int = 2 //error
  3. //const var topData3: Int = 3//error
  4. const val topData4: Int = 10
  5.  
  6. var str: String = "aaa" // ok
  7. var str2 = "bbb" // ok
  8. //var str3: String = null // error
  9. var str4: String? = null // ok
  10. var str5 = """ // ok
  11. abde
  12. efg
  13. high
  14. """.trimIndent()
  15.  
  16. class User {
  17. val objData1: String ="1";// error
  18. var objData2: String ="2";// error
  19.  
  20. fun some(){
  21. const val localData1: Int // error
  22. var localData2: String // ok...
  23.  
  24. println(localData1) // error
  25. localData2="hello" // ok...
  26. println(localData2) // ok...
  27. }
  28. }
  29.  
  30. fun main(args: Array<String>) {
  31. var user: User = User()
  32. user.some()
  33. }
  34.  
Compilation error #stdin compilation error #stdout 0.06s 33228KB
stdin
Standard input is empty
compilation info
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.intellij.openapi.util.JDOMUtil$2 to constructor com.sun.xml.internal.stream.XMLInputFactoryImpl()
WARNING: Please consider reporting this to the maintainers of com.intellij.openapi.util.JDOMUtil$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
JNA Warning: IOException removing temporary files: JNA temporary directory '/tmp' is not writable
prog.kt:21:3: error: modifier 'const' is not applicable to 'local variable'
		const val localData1: Int // error
  ^
prog.kt:24:11: error: variable 'localData1' must be initialized
		println(localData1) // error
          ^
stdout
Standard output is empty