This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun main(args:Array<String>){ | |
| //var_declarations() | |
| ranges() | |
| } | |
| fun ranges(){ | |
| val a: IntProgression =1.rangeTo(10).reversed() | |
| for(x in a) println(x) | |
| println("sum of ints $a = ${a.sum()}") | |
| var b =10.downTo(1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun main(args:Array<String>){ | |
| //var_declarations() | |
| ranges() | |
| } | |
| fun ranges(){ | |
| val a: IntProgression =1.rangeTo(10).reversed() | |
| for(x in a) println(x) | |
| println("sum of ints $a = ${a.sum()}") | |
| var b =10..1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun main(args:Array<String>){ | |
| //var_declarations() | |
| ranges() | |
| } | |
| fun ranges(){ | |
| val a: IntProgression =1.rangeTo(10).reversed() | |
| for(x in a) println(x) | |
| println("sum of ints $a = ${a.sum()}") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun main(args:Array<String>){ | |
| //var_declarations() | |
| ranges() | |
| } | |
| fun ranges(){ | |
| val a: IntProgression =1.rangeTo(10).reversed() | |
| for(x in a) println(x) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun main(args:Array<String>){ | |
| //var_declarations() | |
| ranges() | |
| } | |
| fun ranges(){ | |
| val a=1.rangeTo(10) //1,2,3......,10 | |
| for(x in a) println(x) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun main(args:Array<String>){ | |
| //var_declarations() | |
| ranges() | |
| } | |
| fun ranges(){ | |
| val a:IntRange=1..10 //1,2,3......,10 | |
| for(x in a) println(x) | |
| } | |
| //var_declarations()在下面我就不貼了 以下略 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun main(args:Array<String>){ | |
| var_declarations() | |
| } | |
| fun var_declarations(){ | |
| val a=64 | |
| val b=123 | |
| val c=2.3f ///或F | |
| val d=12.3e5 | |
| println(" $a $b $c $d") | |
| val e:Int; //只有e這邊宣告又沒給值的,一定要給形別 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun main(args:Array<String>){ | |
| var_declarations() | |
| } | |
| fun var_declarations(){ | |
| val a:Int=64 | |
| val b:Long=123 | |
| val c:Float=2.3f ///或F | |
| val d:Double=12.3e5 | |
| println(" $a $b $c $d") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun main(args:Array<String>){ //fun main為程式進入點 ,某版本後可以直接寫fun main(){} 不用寫args:Array<String> | |
| var_declarations() //呼叫執行Function | |
| } | |
| fun var_declarations(){ | |
| val a:Int=64 //val為常數宣告 var才是變數宣告 | |
| val b:Long=123 | |
| val c:Float=2.3f | |
| val d:Double=12.3e5 | |
| println(" $a $b $c $d") //支援在雙引號內直接透過錢字號引用常/變數 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package DIP; | |
| public class Person { | |
| public String name; | |
| public Person(String name) { | |
| this.name = name; | |
| } | |
| } |