基於下面的代碼,我需要通過創建一個名爲employee print()的專用打印方法來修改Employee類中的代碼,並顯示它將如何用於打印員工測試班!請幫忙嗎?下面是代碼:如何創建和使用使用java的打印方法
class Employee1{
String empName;
String empNum;
String empEmailAddress;
int yearOfBirth;
}
public class employeeTest {
public static void main(String[] args) {
Employee1 emp1 = new Employee1();
emp1.empName = "Sam";
emp1.empNum = "213-23-978";
emp1.empEmailAddress = "[email protected]";
Employee1 emp2 = new Employee1();
emp2.empName = "Tasha";
emp2.empNum = "315-90-274";
emp2.yearOfBirth = 1982;
System.out.println("Employee Name: " + emp1.empName);
System.out.println("Employee Number: " + emp1.empNum);
System.out.println("Email Adress: " + emp1.empEmailAddress);
System.out.println("Year of Birth: " + emp1.yearOfBirth);
System.out.println("Employee Name: " + emp2.empName);
System.out.println("Employee Number: " + emp2.empNum);
System.out.println("Email Address: " + emp2.empEmailAddress);
System.out.println("Year of Birth: " + emp2.yearOfBirth);
}
}
你真的應該告訴我們你第一次嘗試的東西。 – rainkinz 2013-03-27 23:24:52
是的,你是對的兄弟,但是這條路很漫長,我想出了這段代碼!它沒有給我這樣的代碼,我經歷了所有的步驟,但我沒能實現最後一步方法!謝謝你的評論兄弟! – user2204281 2013-04-08 16:40:24