zoukankan      html  css  js  c++  java
  • chapter03

    import scala.collection.mutable.ArrayBuffer

    /**
    * Created by EX-CHENZECHAO001 on 2018-03-29.
    */
    class Chapter03 {

    }


    object Chapter03 {


    // 3.5 常用算法
    val arr35 = Array(1, 8, 3, 5, 7)
    val arrb35 = ArrayBuffer(1, 6, 4, 5)
    arr35.sum
    arrb35.sum
    arr35.min
    arr35.max
    arr35.length
    arr35.sorted // 不修改原数组
    scala.util.Sorting.quickSort(arr35) // 修改原数组
    arrb35.sorted
    arrb35.sortWith(_ > _)
    arr35.mkString("|")
    arr35.count(x => x > 0)

    // 3.7 多维数组
    val matrix = Array.ofDim[String](3,4) // 三行四列
    // matrix(row)(column) = 42
    val triangle = new Array[Array[Int]](10)
    for(i <- 0 until triangle.length){
    triangle(i) = new Array[Int](i + 1)
    }

    // 3.8 与Java的互操作
    import scala.collection.JavaConversions.bufferAsJavaList
    import scala.collection.mutable.ArrayBuffer
    val command = ArrayBuffer("ls", "-al", "/home/")
    val pb = new ProcessBuilder(command)

    import scala.collection.JavaConversions.asScalaBuffer
    import scala.collection.mutable.Buffer
    val cmd:Buffer[String] = pb.command()









































    }
  • 相关阅读:
    Linq To Sql 大全
    lambda表达式学习
    一步一步学Linq to sql系列文章
    MVC 学习
    Guava环境设置
    ANT简介
    Quartz特点
    XStream环境设置
    log4j配置
    类是什么?
  • 原文地址:https://www.cnblogs.com/chenzechao/p/8671411.html
Copyright © 2011-2022 走看看