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

相关推荐
数据智能老司机3 天前
函数式事件驱动架构——交易系统(可观测性)
架构·scala·响应式设计
数据智能老司机3 天前
函数式事件驱动架构——带副作用的流
架构·scala·响应式设计
IvanCodes4 天前
二、Spark 开发环境搭建 IDEA + Maven 及 WordCount 案例实战
大数据·spark·scala
渣渣盟14 天前
Flink数据流高效写入MySQL实战
mysql·flink·scala
开开心心就好14 天前
专业PPT图片提取工具,操作简单
javascript·电脑·powerpoint·scala·erlang·perl·myeclipse
开开心心就好17 天前
电脑息屏工具,一键黑屏超方便
开发语言·javascript·电脑·scala·erlang·perl
linweidong1 个月前
一站式用AI编程神奇Cursor/Trae(VScode环境)开发运行Scala应用
大数据·vscode·后端·大模型·scala·ai编程·cursor
白总Server1 个月前
GaussDB 分布式数据库调优(架构到全链路优化)
java·网络·c++·架构·go·scala·数据库架构
小伍_Five1 个月前
spark数据处理练习题番外篇【下】
java·大数据·spark·scala
无人赴约的cat2 个月前
【20250607接单】Spark + Scala + IntelliJ 项目的开发环境配置从零教学
大数据·spark·scala