内部类Dog.DogTestDrive中的非法静态声明
class Dog{
int size;
String breed;
String name;
void bark()
{
System.out.println("Wuff! Wuff!");
}
public class DogTestDrive{
public static void main(String []args)
{
Dog d = new Dog();
d.size = 12;
d.name = "pongy";
d.bark();
d.breed = "Labrodor";
}
}
}
修饰符'静态'只允许在常量变量声明中
答案 0 :(得分:0)
改为代替public class DogTestDrive
- > public static class DogTestDrive
class Dog {
int size;
String breed;
String name;
void bark()
{
System.out.println("Wuff! Wuff!");
}
public static class DogTestDrive {
public static void main(String []args)
{
Dog d = new Dog();
d.size = 12;
d.name = "pongy";
d.bark();
d.breed = "Labrodor";
}
}
}