脸上长大包了郁闷,散分。刚刚写了段代码大家一起分享
package com.neusoft.om.action;/** description * <p>Date : 2012-03-29</p> * <p>Description: 当今程序猿 (普通程序员,2B程序员,文艺程序员)</p> * @author tongdj * @version * <p>------------------------</p> * <p> 修改历史</p> * <p> 序号 日期 修改人 修改原因</p> * <p> 1 </p> */public class Programmer { /** * 普通程序员 */ public String getInfo1(String firstName,String lastName,int age,double height){ String name = firstName + lastName; StringBuffer infoSB = new StringBuffer(); infoSB.append(name); infoSB.append(age); infoSB.append(height); String info = infoSB.toString(); return info; } /** * 2B程序员 */ public String getInfo2(String i,String l,int j,double k){ return i+l+j+k; } /** * 文艺程序员 */ public String getInfo3(String firstName,String lastName,int age,double height){ LiteraryProgrammer ly = new LiteraryProgrammer(firstName,lastName,age,height); return ly.getInfo(); } class LiteraryProgrammer{ private final String name; private final int age; private final double height; public LiteraryProgrammer(String firstName,String lastName, int age, double height) { super(); this.name = firstName + lastName; this.age = age; this.height = height; } public String getInfo(){ return new StringBuilder().append(name).append(age).append(height).toString(); } }}