博客
关于我
Scala_1.控制台打印,变量定义,函数定义
阅读量:301 次
发布时间: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/

你可能感兴趣的文章
【论文泛读03】卷积LSTM网络:一种短时降雨量预测的机器学习方法
查看>>
中科大-凸优化 笔记(lec45)-强凸性等价不等式
查看>>
linux 中 alien命令的使用
查看>>
【论文泛读29】关系抽取:卷积神经网络的视角
查看>>
shell 中的 set命令 -e -o 选项作用
查看>>
Python中JSON的基本使用
查看>>
函数的默认参数值,即在定义参数的时候给它一个默认值
查看>>
ubuntu install baidu inputmethod
查看>>
程序员建议(忘记从哪里转的了,反正是csdn上的一个兄弟)
查看>>
电脑重装系统后提示invalid partition table怎么解决
查看>>
c++ primer 5th 练习11.9自己编写的答案
查看>>
web实现断点续传
查看>>
自定义BootstrapTable扩展:分页跳转到指定页码
查看>>
【学习笔记】欧拉函数,欧拉公式
查看>>
Python3序列
查看>>
React中设置404页面
查看>>
BootstrapValidator手动触发部分验证
查看>>
vue调试工具vue-devtools安装及使用
查看>>
CSS总结div中的内容垂直居中的四种方法
查看>>
[BZOJ4878]挑战NP-Hard
查看>>