Scala的Tuple、Array、Map和文件操作

package com.sysu.jerry

import scala.io.Source

object c2 {
  def main(args: Array[String]):Unit = {
    //*********************  tuple ***********************************//
   /* val triple = (100,"Scala","Spark")
    println(triple._1)
    println(triple._2)
    println(triple._3)*/
    
    
    
     //*********************  Array ***********************************//
    /*val array = Array(1,2,3,4,5)
    for (i <- 0 until array.length){
      println(array(i))
    }
    
    for (elem <- array){
      println(elem)
    }*/
    
    
    
     //*********************  Map ***********************************//
    //val ages = Map("Rokey" -> 27, "Spark"->5)
    
    /*for((k,v) <- ages){
      println("Key is:" + k + ",value is " + v)
    }*/
    
    /*for((k,_) <- ages){
      println("Key is " + k)
    }*/
    
    
     //*********************  文件操作   ***********************************//
    //val file = Source.fromFile("E:\\1.txt")   
    val file = Source.fromURL("http://spark.apache.org/downloads.html")
    for(line <- file.getLines){
      println(line)
    }
    
    
    
  }
}


你可能感兴趣的:(Scala的Tuple、Array、Map和文件操作)