Twoclassescannotbeputin a.java file.
Forexample :
publicclassFinalTest
{
String color="yellow";
publicvoidgetMes()
{
System.out.println("parent class variable of color: "+color);
}
}
/
publicclasstest extendsFinalTest
{
String color="blue";
publicvoidgetMes()
{
System.out.println("child class variable of color: "+color);
}
public staticvoidmain (String[] args)
{
test t=newtest();
t.getMes();
}
}
Thought it's a simply programming ,it took me nearly half an hour to check out where goes wrong.---I put them in a same .java file ,and hadn't create a test.java in the package folder.
PS:A function which is the type of final cannot be rewrite in its child class .