java 有返回值方法调用

来源:互联网 发布:鲁滨逊漂流记java安卓 编辑:程序博客网 时间:2024/05/17 22:04

源程序:

public class Test{
 public static void main(String args[]){
  int one = addOne(10 , 20);
  float two = addTwo(13.6f ,23.4f) ;
  System.out.println("addOne的结果:" + one) ;
       System.out.println("addTwo的结果: " + two) ;
 }
 public static int addOne(int x , int y){
  int temp ;
  temp = x + y ;
  return temp ;
 }
    publicstatic float addTwo(float x , float y){
  float temp ;
  temp = x + y ;
  return temp ;
 }
}

运行结果:

java <wbr>有返回值方法调用

0 0