JAVA面向对象的学习
定义类的方法
class 类名
{
属性:
方法;
}
属性:也叫成员变量,主要用于描述类的状态
方法:也叫成员方法,主要用于类的行为
class person {
int age;
void shout(){
System.out.println("Oh my");
}
}
生成对象的方法
类名 对象名=new 类名
格式:Dog dog=new Dog();
定义类的方法
class 类名
{
属性:
方法;
}
属性:也叫成员变量,主要用于描述类的状态
方法:也叫成员方法,主要用于类的行为
class person {
int age;
void shout(){
System.out.println("Oh my");
}
}
生成对象的方法
类名 对象名=new 类名
格式:Dog dog=new Dog();
本文标题:2020-02-24
本文链接:https://www.haomeiwen.com/subject/ptziqhtx.html
网友评论