类的无参方法(2)

public class AutoLionTest {
public static void main (String[]args){
//如何创建AutoLion类的对象
/**
* 类的实例化过程
*/
AutoLion lion=new AutoLion();
lion.color="黄色";

//方法执行完毕后,将return的值带过来了
/**
* 怎么接受返回值
*/
String ball=lion.playBall();
int age=lion.getAge();
System.out.println(age);
}
}

猜你喜欢

转载自www.cnblogs.com/F017/p/9782608.html