Scala day2(val var function)

Foreword

Hello!! My dear friends, we also meet in this passage. I know you already stronger than before, because I am a common person, so I learn something is specially slow. I like share my knowledge, I hope it will give you some helps, I am not a Big Cow, so I support open source.

Text

At first, we look the val and var type in Dos【isn't use IDEA】, the Dos window could help us to find the scala work process stream【IDEA isn't show Data Type】. Now!! we will start to learn scala, you know my rules, we should code one sentence to start today content: System.out.println("Scala is make me happy!!"). Then look the below picture:

From the above picture, we know the val define constant, var define variable, val could calculate like var, but val couldn't assign value.【it couldn't change】.

Next, we continue to look the below codes.

scala 复制代码
//The codes in file day2.scala
object day2 {
  def main(args:Array[String]): Unit = {
    System.out.println("Scala is make me happy!!");
    Compare_value(34,21);
    Compare_value(21,45)
    Compare_value(32,32)

  }

  def Compare_value(x:Int,y:Int): Unit = {
    if(x > y)
      System.out.println(x+" > "+y)
    else if(x == y){
      System.out.println(x+" = "+y)
    }
    else{
      System.out.println(x+" < "+y)
    }
  }
}

Output result:

Through the program, we know define function could setting several parameters, it need use , separate these parameters, also after every parameter use : to concern itself data type. We together know the if only have one sentence, it could haven't brace to include content. We also know scala coding style is like java or python.【it could select to use ; over the sentence, if you not do that, it could accept】

In the end

I gratitude for your read my articles, though my articles maybe have some mistakes, I hope you could point them, I thanks for you. In my opinion, you already study with me, Scala isn't simple for Beginer, you will meet all kinds of problems on the study road, but you insist do it is very cool!! Please you remember anything give up is so easy, but you lived at last then you were strongest!!

Your Pan, my dear friends, Cheers!!

相关推荐
闯闯桑2 天前
toDF(columns: _*) 语法
开发语言·前端·spark·scala·apache
q567315233 天前
无需Python:Shell脚本如何成为你的自动化爬虫引擎?
开发语言·爬虫·python·自动化·scala
渣渣盟5 天前
Spark自定义累加器实现高效WordCount
大数据·spark·scala
IvanCodes5 天前
一、Scala 基础语法、变量与数据类型
大数据·开发语言·scala
q567315236 天前
Nim轻量级爬虫:异步高效+代理轮换防封
开发语言·后端·爬虫·typescript·scala
哈哈很哈哈6 天前
Scala协变、逆变、上界/下界、隐式参数、隐式转换
开发语言·后端·scala
更深兼春远19 天前
spark+scala安装部署
大数据·spark·scala
还是大剑师兰特22 天前
Scala面试题及详细答案100道(11-20)-- 函数式编程基础
scala·大剑师·scala面试题
华科云商xiao徐1 个月前
响应式爬虫系统设计:Scala异步任务编排与弹性容错机制
爬虫·scala
ChipCamp1 个月前
Chisel芯片开发入门系列 -- 18. CPU芯片开发和解释8(流水线架构的代码级理解)
开发语言·青少年编程·fpga开发·scala·dsp开发·risc-v·chisel