赞
踩
kotlin入门学习-勿喷
fun main(args:Array<String>) {
println("HelloWorld");
}
05_kotlin变量与输出_01
05_kotlin变量与输出_02
变量的声明与使用 fun main(args:Array<String>) { //println("HelloWorld"); var name = "张三" println(name) } 打印: 张三 var name = "张三" name = "lisi" println(name) 打印: lisi 错误:The integer literal does not conform to the expected type String var name = "张三" name = "lisi" name = 8 println(name)
06_kotlin二进制基础_01
07_kotlin变量和常量&类型推断_01
变量 var number1 = "变量,可赋值" 错误:The integer literal does not conform to the expected type Int var i = 18 i = 19 i = 999999999999999999 var k:Byte = 25 (-127~128) 智能类型推断 var j = 999999999999999999 显式指定类型: var i:Int = 18 var j:Long = 999999999999999999 var s:String = "haha" 错误:This variable must either have a type annotation or be initialized var a 改: var a:Int 常量 val number2 = "常量,只读"
08_kotlin变量取值范围_01
val aByte:Byte = Byte.MAX_VALUE
val bByte:Byte = Byte.MIN_VALUE
println("最大值:"+ aByte)
println("最小值:"+ bByte)
val aLong:Long = Long.MAX_VALUE
val bLong:Long = Long.MIN_VALUE
println("最大值:"+ aLong)
println("最小值:"+ bLong)
val aInt:Int = 0b0011
println("aInt:"+ aInt)
09_kotlin函数入门_01
10_kotlin语言boolean_01
var num1 = 4
val num2 = 6
println(num1 < num2)
var num3 = Math.sqrt(5.0) - Math.sqrt(4.0)
var num4 = Math.sqrt(4.0) - Math.sqrt(3.0)
println(num3 - num4)
var num5 = Math.pow(2.0, 100.0)
var num6 = Math.pow(3.0, 75.0)
println(num5 < num6)
11_kotlin命令行交互式终端_01
12_kotlin函数加强_01
12_kotlin函数加强_02
fun main(args: Array<String>) { var a = 8 var b = 2 println("a+b="+ plus(a,b)) println("a-b="+ sub(a,b)) println("a*b="+ mutl(a,b)) println("a/b="+ devide(a,b)) } fun plus(a: Int, b: Int): Int { return a + b } fun sub(a: Int, b: Int): Int { return a - b } fun mutl(a: Int, b: Int): Int { return a * b } fun devide(a: Int, b: Int): Int { return a / b }
13_kotlin函数作业讲解_01
fun main(args: Array<String>) {
var name = "张三"
var personName = sayHello(name)
println(personName)
}
fun sayHello(name: String): String {
return "hello" + name
}
fun checkAge(age: Int): Boolean {
if (age > 18) return true
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。