这是我的密码:
static class Developer
{
String Name;
String Language;
int Years;
int Age;
void Company ()
{
System.out.println (Name + " Codes in " + Language + " & has " + Years +
" Years of experience" + ", He is " + Age + " Old");
}
public Developer ()
{
System.out.println ("Hello");
}
public Developer (String Name, String Language, int Years, int Age)
{
this ();
this.Name = Name;
this.Language = Language;
this.Years = Years;
this.Age = Age;
}
class Analyst extends Developer
{
public Analyst (String Name, String Language, int Years, int Age)
{
super (Name, Language, Years, Age);
}
}
}
public static void main (String[]args)
{
Developer d1 = new Developer ();
d1.Name = "John";
d1.Language = "Java";
d1.Years = 2;
d1.Age = 22;
Developer d2 = new Developer ("Doe", "C++", 3, 23);
d1.Company ();
d2.Company ();
Analyst A1 = new Analyst ("Doe", "C++", 3, 23);
A1.Company ();
}
}
获取以下错误:
Main.java:58: error: cannot find symbol
Analyst A1 = new Analyst("Doe","C++",3,23);
^
symbol: class Analyst
location: class Main
Main.java:58: error: cannot find symbol
Analyst A1 = new Analyst("Doe","C++",3,23);
^
symbol: class Analyst
location: class Main
2 errors
2条答案
按热度按时间txu3uszq1#
fzsnzjdm2#
您不能使用
static
关键字,除非它是内部类。一static
内部类是一个嵌套类,它是static
外层阶级的成员。