JAVA基础三——函数

来源:互联网 发布:linux vps python 编辑:程序博客网 时间:2024/05/01 23:29

代码实例:

package  com;public  class  Test {     /**      * 数字相加      * @param a 形式参数      * @param b 形式参数      * @return 返回int 这个结果是a+b      */     public  static  int  add( int  a, int  b){         int  c = a+b; //执行语句         toString(a,b);         return  c;     }          public  static  void  toString( int  a, int  b){         System.out.println( "长:" +a);         System.out.println( "宽:" +b);              }               public  static  void  main(String[] args) {                  //实际参数         int  x =  12 ;         int  y =  34 ;                  int  sum = Test.add(x, y);                  System.out.println( "和:" +sum);              /*             Test.toString(12,12);         */     }          } 


0 0
原创粉丝点击