我刚开始,这真的让人困惑,因为当我编写代码时,eclipse上没有红色警告,但是当我运行该程序时,它不起作用。 的问题是:雇员,名字,姓氏和编号
编写显示雇员的ID和员工的名字和姓氏的程序。使用两个类。第一类包含员工数据和单独的方法来设置ID和名称。另一个类为员工创建对象并使用这些对象调用set方法。创建几个员工并显示他们的数据。
我的代码是:
public class Employee {
String lastName = null;
String firstName = null;
double ID;
public Employee(String lastName, String firstName, double ID){
this.lastName = lastName;
this.firstName = firstName;
this.ID = ID;
}
public String empStat(){
return "Last Name: " + lastName + "First Name: " + firstName + "ID" + ID;
}
}
和
public class MainEmployee {
public static void main(String args[]){
Employee nub1 = new Employee ("Griffin", "Peter", 000001);
System.out.println(nub1);
Employee nub2 = new Employee ("Griffin", "Lois", 000002);
System.out.println(nub2);
Employee nub3 = new Employee ("Griffin", "Stewie", 000003);
System.out.println(nub3);
Employee nub4 = new Employee ("Griffin", "Brian", 000004);
System.out.println(nub4);
}
}
和所有它的作用是显示
[email protected] [email protected] [email protected] [email protected]
有人可以告诉我为什么?
请注意:[JavaScript不是JAVA](http://kb.mozillazine.org/JavaScript_is_not_Java) – mplungjan
不要养成零填充数字的习惯。 '000010'不是你认为的数字。另见http://stackoverflow.com/questions/5206342/what-is-an-illegal-octal-digit/5206381#5206381 –