Examples of books
package helloworldapp;
public class first
{
class J_Employee
{
public int m_workYear;
public J_Employee()
{
m_workYear = 1;
}
}
public class J_Teacher extends J_Employee
{
public int m_classHour;
public J_Teacher()
{
m_classHour = 96;
}
public void mb_printInfo()
{
System.out.println("该教师的工作年限为"+m_workYear);
System.out.println("该教师的授课课时为"+m_classHour);
}
public static void main(String args[])
{
J_Teacher tom = new J_Teacher();
tom.mb_printInfo();
}
}
}
What is wrong ? ? If the main place outside the class , does not work, seek solutions ! !
------ Solution ---------------------------------------- ----
landlord right main move out, and then changed to the following:
public static void main(String args[])
{
PolymorphismTest pltt=new PolymorphismTest();
PolymorphismTest.J_Teacher tom=pltt.new J_Teacher();
tom.mb_printInfo();
}
This should clearly know why the wrong bar ?
------ For reference only -------------------------------------- -
main (String args [])
should be String [] args
------ For reference only -------------------------- -------------
I prawn up ! !
没有评论:
发表评论