val start =1val end =10for(i <- start to end){
println("hello,scala!!")}
说明:
1、start 表示是从那个数开始循环。
2、to 是关键字。
3、end 是循环结束的值。
4、start to end 表示前后闭合(即包含头也包含尾)
scala流程控制之for循环scala中for循环的两种方式第一种循环方式val start = 1val end = 10for (i <- start to end) { println("hello,scala!!")}说明: 1、start 表示是从那个数开始循环。 2、to 是关键字。 3、end 是循环结束的值。 4、start to end 表示前后闭合(即包含头也包含尾)防坑:在scala中for循环中以to关键字连接的范围既