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 天前
深兰科技受邀参与第二届中国(南宁)—东盟人工智能场景应用对接会,深化AI国际合作
人工智能·qt·r语言·scala·symfony·智能机器人·深兰科技
开开心心就好9 天前
低年级识字练笔顺工具,电脑和安卓端都能用
前端·javascript·网络·安全·scala·erlang·语音识别
开开心心就好11 天前
清理此电脑网盘图标工具,开源免费好用
网络·网络协议·tcp/ip·智能手机·电脑·scala·erlang
典典分享指南14 天前
用结构化数据管理产品知识库
scala·bash·batch·actionscript
Thomas214317 天前
scala 闭包
开发语言·后端·scala
江畔柳前堤17 天前
前台·中台·后台:2026年AI原生时代的架构全景图
开发语言·人工智能·算法·机器学习·架构·scala·ai-native
Thomas214325 天前
Java scala 数组 链表
java·链表·scala
江畔柳前堤1 个月前
消息队列:从直觉到精通的完整认知地图
开发语言·人工智能·算法·机器学习·ruby on rails·scala
hopsky1 个月前
《Scala 学习手册》核心内容详解
人工智能·学习·scala
abcy0712132 个月前
scala playframework 搭建与新建controller教程
scala