大神来看下,问什么照着书上的例子写到myecliose报错??
下面是源代码跟书上一样的但是到myecliose就是报错,把public去掉就可以了这是为啥??
package day20131105;
public class ExtendsType {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Person [] p = new Person[2];
Person[0]= new Employee("张三",5000);
Person[1]= new Student("李四","科学家");
}
}
abstract class Person{
private String name;
public Person(String n)
{
name=n;
}
public abstract String getDescripution();
public String getname(){
return name;
}
}
public class Employee extends person{
private double salary;
public Employee(String n,double s) {
super(n);
salary =s;
// TODO Auto-generated constructor stub
}
public double getsalary(){
return salary;
}
public String getDescripution(){
return String.format("the employee'salary is ", salary);
}
}
public class student extends person{
private String major;
public student(String n,String m) {
super(n);
// TODO Auto-generated constructor stub
major = m;
}
public String getDescripution(){
return String.format("the Student is ", major);
}
}
------解决方案--------------------你一个.java文件中只能有一个public class。而且这个class名字和文件名要一直