Java tutorial
//package com.java2s; public class Main { public static String genGetter(String fieldName) { return upperFirstAndAddPre(fieldName, "get"); } public static String upperFirstAndAddPre(String str, String preString) { if (str == null || preString == null) { return null; } return preString + Character.toUpperCase(str.charAt(0)) + str.substring(1); } }