public class Test1 {
public static void main (String args[]) {
Cat cat1 = new Cat();
cat1.speak();
cat1.jiSuan();
cat1.jiSuan(2);
cat1.sum(2, 2);
}
}
class Cat
{
int age ;
String name;
String colour;
public void speak()
{
System. out.println("我是一个好人" );
}
public void jiSuan()
{
int result=0;
for(int i=0;i<=1000;i++)
{
result+=i;
}
System. out.println(+result);
}
public void jiSuan(int n)
{
int result =0;
for (int i=0;i<=n;i++)
{
result+=i;
}
System. out.println(+result);
}
public void sum(int sum1,int sum2)
{
int result=0;
result= sum1+sum2;
System. out.println(+result);
}
//计算两个数的和,并把结果返回调用他的函数
public int sum2(int sum1,int sum2)
{
return sum1+sum2;
}
}