根据提供的代码,可以看到在创建Cat对象时,Cat类的定义应该在创建对象之前。请将Cat类的定义放在创建对象之前的位置。以下是修正后的代码:

public class Cat {
    String name;
    int age;
    int health;
    String breed;

    public Cat(String name, int age, int health, String breed) {
        this.name = name;
        this.age = age;
        this.health = health;
        this.breed = breed;
    }
}

Cat cat = new Cat("咪咪", 6, 70, "田园猫");

这样就能够正确解析Cat为类型了。

Cat cat = new Cat咪咪670田园猫; public class Cat 	String name; 	int age; 	int health; 	String breed; 	 	public CatString name int age int health String breed 		thisname = name; 		thisage = age; 		thish

原文地址: https://www.cveoy.top/t/topic/imXK 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录