1、
class Address { private String country; private String province; private String city; private String street; private String postcode; Address() { } Address(String country, String province, String city, String street, String postcode) { this.country = country; this.province = province; this.city = city; this.street = street; this.postcode = postcode; } public void show() { System.out.println("地址为:"+country+province+city+street+" 邮编: "+postcode); } } public class AddressTest { public static void main(String[] args) { new Address("中国", "湖北省", "天门市", "陆羽大道", "427806").show(); } }
2、
class Employee { private String id; private String name; private double base_salary; private double increase_salary; Employee(String id, String name, double base_salary, double increase_salary) { this.id = id; this.name = name; this.base_salary = base_salary; this.increase_salary = increase_salary; } public double getIncrease_salary() { return increase_salary; } public double getTotalSalary() { return increase_salary + base_salary; } } public class EmployeeDemo { public static void main(String[] args) { Employee li = new Employee("211016040", "李阿昀", 5000, 2500.50); System.out.println("薪水增长额:"+li.getIncrease_salary()); System.out.println("增长后的工资总额为:"+li.getTotalSalary()); } }
3、
原文:http://www.cnblogs.com/yerenyuan/p/5236692.html