java之Employee
Posted 业余py
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java之Employee相关的知识,希望对你有一定的参考价值。
package learning;
import java.util.*;
import java.io.*;
public class Employee{
String name;
int age;
String designation;
double salary;
public Employee(String name) {
this.name = name;
}
public void empAge(int empAge) {
age = empAge;
}
public void empDesignation(String empDesig) {
designation = empDesig;
}
public void empSalary(double empSalary) {
salary = empSalary;
}
public void printEmployee() {
System.out.println("名字:"+ name);
System.out.println("年龄:"+ age);
System.out.println("职位:"+ designation);
System.out.println("薪水:"+ salary);
}
}
public class EmployeeTest {
public static void main(String args[]){
Employee empOne = new Employee("RUNOOB1");
Employee empTwo = new Employee("RUNOOB2");
empOne.empAge(26);
empOne.empDesignation("高级程序员");
empOne.empSalary(1000);
empOne.printEmployee();
empTwo.empAge(21);
empTwo.empDesignation("菜鸟程序员");
empTwo.empSalary(500);
empTwo.printEmployee();
}
}
以上是关于java之Employee的主要内容,如果未能解决你的问题,请参考以下文章
在java中为什么要把main方法定义为一个static方法?