博客
关于我
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 高可用性之keepalived+mysql双主
查看>>
mysql-connector-java各种版本下载地址
查看>>
mysql-group_concat
查看>>
MySQL-【4】基本操作
查看>>
Mysql-丢失更新
查看>>
Mysql-事务阻塞
查看>>
Mysql-存储引擎
查看>>
MySQL-数据目录
查看>>
MySQL-数据页的结构
查看>>
MySQL-架构篇
查看>>
Mysql-触发器及创建触发器失败原因
查看>>
MySQL-连接
查看>>
mysql5.5和5.6版本间的坑
查看>>
mysql5.5最简安装教程
查看>>
mysql5.6 TIME,DATETIME,TIMESTAMP
查看>>
mysql5.6.21重置数据库的root密码
查看>>
Mysql5.6主从复制-基于binlog
查看>>
MySQL5.6忘记root密码(win平台)
查看>>
MySQL5.6的Linux安装shell脚本之二进制安装(一)
查看>>