提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
带有构造函数的Cat类
public class Main { public static void main(String[] args) { // Create a Cat object and ignore its reference/*时 代 Java - nowjava.com*/ new Cat(); // Create another Cat object and store its reference in c Cat c = new Cat(); } } class Cat { public Cat() { System.out.println("Meow..."); } }