1、创建工程,包,类。。。
2、首先创建一个职工类Employee(public class Employee{)定义初始化变量(String name,sex,department; int age,no;)
3、构造方法:磕聆霖麸无参(public Employee(){};)三参(public Employee(String name, int 荏鱿胫协no, String department){ this.name=name; this.no=no; this.department=department; })五参(public Employee(String name, String sex, int age, int no, String department){ this.name=name; this.sex=sex; this.age=age; this.no=no; this.department=department; })
4、创建一个work方法用于格式输出(public void work(){ System.out.println("该职工姓名为:"+name+"\t"+"性别:"+sex+"\t"+"年龄:"+age+"\t" +"工号:"+no+"\t"+"所属部门:"+department); })
5、输入对象数据并输出(public static void main(String[] args){ Employee E1=new 呶蓟鹭毵Employee(); E1.work(); Employee E2=new Employee("小明",20171102,"信息系"); E2.work(); Employee E3=new Employee("小红","女",20171103,18,"信息系"); E3.work(); }})
6、总览代码