zoukankan      html  css  js  c++  java
  • Scala-基础-函数(1)

    import junit.framework.TestCase
    
    //函数(1)
    class Demo5 extends TestCase {
      
        
        
        def testDemo(){
          println("开始测试Scala函数");
          method_0();
          var t1 = 10;
        }
      
        //函数-无参数列表-无返回值
        def method_0(){
          println("函数-无参数列表-无返回值");
        }
        def scala_method_a():Unit={
            println("函数-无参数列表-无返回值-:Unit=-可以忽略");
        }
        //函数-单参数列表-无返回值
        def scala_method_a(x:Int){
              println("函数-单参数列表-无返回值");
        }
        //函数-多参数列表-无返回值
        def scala_method_a(x:Int,y:Int){
          println("函数-多参数列表-无返回值");
        }
        //函数-无参数列表-有返回值
        def scala_method_b():Int={
          var rs = 10;
          println("函数-无参数列表-有返回值");
          return rs;
        }
        def scala_method_c():Int={//可以忽略return
                var rs = 10;
                 rs;
        }
        //函数-单参数列表-有返回值
        def scala_method_b(x:Int):Int={
          println("函数-单参数列表-有返回值");
            x;
        }
        //函数-多参数列表-有返回值
        def scala_method_b(x:Int,y:Int):Int={
          println("函数-多参数列表-有返回值");
            x+y;
        }
        
        
    }
  • 相关阅读:
    Python中下划线---完全解读(转)
    数字、基数及表示
    实现二叉排序树的各种算法
    shell脚本 空格
    Linux中执行shell脚本的4种方法
    vim常用命令总结
    Linux 奇技淫巧
    排序算法之二分治法
    二分查找
    排序算法之一插入排序
  • 原文地址:https://www.cnblogs.com/ak23173969/p/6782273.html
Copyright © 2011-2022 走看看