首页 > 其他分享 >无参构造oppdemo3

无参构造oppdemo3

时间:2022-10-13 10:00:54浏览次数:55  
标签:无参 System Pet dog 构造 oppdemo3 public out

public class Pet {

public String name;
public int age;

//无参构造
public void shout(){
System.out.println("叫了一声");
}
}

public class Application {
public static void main(String[] args) {

Pet dog = new Pet();
dog.name = "旺财";
dog.age = 5;
dog.shout();
System.out.println(dog.name);
System.out.println(dog.age);

Pet cat = new Pet();

}
}

标签:无参,System,Pet,dog,构造,oppdemo3,public,out
From: https://www.cnblogs.com/123jgh/p/16787062.html

相关文章