Java examples for Reflection:Getter
get Getter Method Name
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { String property = "java2s.com"; System.out.println(getGetterMethodName(property)); }/* ww w . j a v a 2 s. c o m*/ public static String getGetterMethodName(String property) { StringBuilder sb = new StringBuilder(); sb.append(property); if (Character.isLowerCase(sb.charAt(0))) { if (sb.length() == 1 || !Character.isUpperCase(sb.charAt(1))) { sb.setCharAt(0, Character.toUpperCase(sb.charAt(0))); } } sb.insert(0, "get"); return sb.toString(); } }