博客
关于我
Scala_1.控制台打印,变量定义,函数定义
阅读量:317 次
发布时间:2019-03-04

本文共 1537 字,大约阅读时间需要 5 分钟。

Scala_1.控制台打印,变量定义,函数定义

package com.liusimport scala.util.control._object HelloWorld {  def main(args: Array[String]): Unit = {////    printStr()                   //打印输出//    variablePractice()           //变量练习//    strOperation()               //字符串操作//    println(functionName(12,5))  //函数操作  }  /**   * 打印练习   */  def printStr():Unit={    println("Hello World!")    println(10)    print("Hello World!")  }  /**   * 变量练习   */  def variablePractice():Unit={    val x =10    var y = 10    y =20    val z:Int = 10    val a:Double = 1.0    val b:Double = 10.0    println("Hello World".length)    println("Hello World".substring(2,6))    println("Hello World".replace("H","3"))    println("Hello World".take(5))  //Hello    println("Hello World".drop(5))  // World  }  /**   * 字符串操作   */  def strOperation():Unit={    //s""    val  n = 45    println(s"We have $n apples")    val c = Array(11,9,6)    println(s"My Second daughter is ${c(0)-c(2)} years old.")    println(s"We have double the amount of ${n/2.0} in apples.")    println(s"Power of 2:${math.pow(2,2)}")    //f""    println(f"Power of 5:${math.pow(5,2)}%1.0f")    println(f"Square of 122:${math.sqrt(122)}%1.4f")    //raw""    println(raw"New line feed:\n.Carriage return:\r.")    println("They stood outside the \"Rose and Crown\"")    val html =      """       

Press belo',Joe

""" println(html) } /** * 函数练习 * @param a * @param b * @return */ def functionName(a:Int,b:Int):Int={// println(a+b) return a+b; }}

 

转载地址:http://ysnq.baihongyu.com/

你可能感兴趣的文章
mysql以下日期函数正确的_mysql 日期函数
查看>>
mysql以服务方式运行
查看>>
mysql优化--索引原理
查看>>
MySQL优化之BTree索引使用规则
查看>>
MySQL优化之推荐使用规范
查看>>
Webpack Critical CSS 提取与内联教程
查看>>
mysql优化概述(范式.索引.定位慢查询)
查看>>
MySQL优化的一些需要注意的地方
查看>>
mysql优化相关
查看>>
MySql优化系列-优化版造数据(存储过程+函数+修改存储引擎)-2
查看>>
MySql优化系列-进阶版造数据(load data statment)-3
查看>>
MySql优化系列-造数据(存储过程+函数)-1
查看>>
MySQL优化配置详解
查看>>
Mysql优化高级篇(全)
查看>>
mysql会员求积分_MySql-统计所有会员的最高前10次的积分和
查看>>
mysql会对联合索性排序优化_MySQL索引优化实战
查看>>
MySQL作为服务端的配置过程与实际案例
查看>>