class Fu
{
void show()
{
System.out.println("fu show");
}
}
class Zi extends Fu
{
void show()
{
System.out.println("zi show");
}
}
class text2
{
public static void main(String[] args)
{
Zi.f = new Zi(); //其实之前是想测试 Fu.f=new Zi();的。。但是。。
f.show();
}
}
如图代码
后面发现无论干什么按 类型 类名 = new 类名(); 都只能创建出了非主类class的文件,但是一到类名定位的变量就显示出错。。
JDK reports that the symbol cannot be found is the punctuation mark, or the variable name is written incorrectly.
What the person above said is correct. "The first letter of a class must be capitalized". In fact, there is nothing wrong if it is not capitalized (the program can still run normally).
但是
It is the norm to capitalize the first letter of a class. (I guess Liz has never been exposed to programming development at work)So is the code.
Class
It is recommended to capitalize the first letter, these建议
can be understood as必须
.Tell me about the line where you made a mistake
Creates an object of type
f
namedzi
.In addition, it is best to contain only one Class in a Class file
---Based on your updated answer.
First of all, point out a serious problem.
The first letter of class zi must be capitalized. See the java ostrich naming table.
This line of code directly Zi f=new Zi();
This is how new constructs an object.