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

相关推荐
lucky_syq6 天前
Scala与Spark算子:大数据处理的黄金搭档
开发语言·spark·scala
深兰科技8 天前
廊坊市市长刘媛率队到访深兰科技,推动机器人制造基地与产业投资落地
人工智能·科技·机器人·scala·symfony·深兰科技·廊坊市市长刘媛
萧霍12 天前
判断两个对象是相等的
scala
程序员小羊!14 天前
Flink(用Scala版本写Word Count 出现假报错情况解决方案)假报错,一直显示红色报错
flink·word·scala
173117 天前
scala中访问控制与方法重写
scala
张较瘦_19 天前
[论文阅读] 从 5MB 到 1.6GB 数据:Java/Scala/Python 在 Spark 中的性能表现全解析
java·python·scala
还是大剑师兰特24 天前
Scala面试题及详细答案100道(81-90)-- 框架与生态
scala·大剑师·scala面试题
孤岛奇兵常凯申25 天前
Scala中的高阶函数(一)
scala
盛小夏1 个月前
用 Python 把汉诺塔玩成“魔法”:从递归到可视化,一篇就够!
scala
智海观潮1 个月前
学好Spark必须要掌握的Scala技术点
大数据·spark·scala