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!!

相关推荐
强化实验室5 天前
如何设计基于吖啶生物素,Acridinium-Biotin的高效生物检测体系?
flask·scala·pyqt·fastapi·web3.py
m0_7482546612 天前
Perl 变量类型
spark·scala·perl
是阿威啊22 天前
【用户行为归因分析项目】- 【企业级项目开发第五站】数据采集并加载到hive表
大数据·数据仓库·hive·hadoop·spark·scala
是阿威啊25 天前
【用户行为归因分析项目】- 【企业级项目开发第四站】模拟三类用户行为数据上传到Hadoop
大数据·hadoop·分布式·sql·scala
今天没有盐1 个月前
Python字符串操作全解析:从基础定义到高级格式化
后端·scala·编程语言
是阿威啊1 个月前
【用户行为归因分析项目】- 【企业级项目开发第一站】项目架构和需求设计
大数据·hive·hadoop·架构·spark·scala
代码于老总1 个月前
【Scala 技巧】用隐式类给 String “开挂”:一行代码实现手机号 / 身份证号校验
scala
scala舔狗汪1 个月前
scala的隐式对象和隐式类
scala
是阿威啊1 个月前
【maap-analysis】spark离线数仓项目完整的开发流程
大数据·分布式·spark·scala
豚踢兔x1 个月前
正则表达式应用-手机号打码
scala