aaarong
发贴: 24
积分: 0
|
于 2007-04-18 23:30
class add { static double add1(double x,double y) { double z,a=0; z=x+y; System.out.println("z="+z); x=x+3.2;y=y+1.2; System.out.println("x="+x+"\ty="+y); return a; //返回的是a 的值 a 为double 型 } static double add2(double y1,double y2) { double z; z=y1+y2+2.9; return z; } }
public class c4_12 { public static void main(String[] args) { add A=new add(); int a=2,b=7; double f1=2,f2=4,f3; A.add1(a,b); //同denghouming 改的一样. // System.out.println(A.add1(a,b));// 所以这句输出才会输出a 的值呀. System.out.println("a="+a+"\tb="+b); f3=2+A.add2(f1,f2); System.out.println("f1="+f1+"\tf2="+f2+"\tf3="+f3); } }
|