博客
关于我
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底层概述—4.InnoDB数据文件
查看>>
MySQL底层概述—5.InnoDB参数优化
查看>>
MySQL底层概述—6.索引原理
查看>>
MySQL底层概述—7.优化原则及慢查询
查看>>
MySQL底层概述—8.JOIN排序索引优化
查看>>
MySQL底层概述—9.ACID与事务
查看>>
Mysql建立中英文全文索引(mysql5.7以上)
查看>>
mysql建立索引的几大原则
查看>>
Mysql建表中的 “FEDERATED 引擎连接失败 - Server Name Doesn‘t Exist“ 解决方法
查看>>
mysql开启bin-log日志,用于canal同步
查看>>
MySQL开源工具推荐,有了它我卸了珍藏多年Nactive!
查看>>
MySQL异步操作在C++中的应用
查看>>
MySQL引擎讲解
查看>>
Mysql当前列的值等于上一行的值累加前一列的值
查看>>
MySQL当查询的时候有多个结果,但需要返回一条的情况用GROUP_CONCAT拼接
查看>>
MySQL必知必会(组合Where子句,Not和In操作符)
查看>>
MySQL必知必会总结笔记
查看>>
MySQL快速入门
查看>>
MySQL快速入门——库的操作
查看>>
mysql快速复制一张表的内容,并添加新内容到另一张表中
查看>>