class SumTest
{
public void main(String[] args)
{Sum a=new Sum(10,1);
Sum b=new Sum(20,11);
a.add1(a);
b.add1(b);
}
}
class Sum
{private int max;
private int min;
/*public Sum(int max,int min ,Sum a )
{this.max=max;
this.min=min;
this.a=a;
}*/
public Sum( )
{
}
public Sum(int max,int min )
{this.max=max;
this.min=min;
}
public static int add1(Sum a)
{ int b=0;
for (int i=a.min;i<=a.max;i++)
{ b+=i;}
System.out.println("输出的结果为"+b);
return b;
}
} |
|