Java Getter Name Create toGetter(final String field)

Here you can find the source of toGetter(final String field)

Description

Converts a field name into a getter method name.

License

Open Source License

Parameter

Parameter Description
field the field name to convert

Return

the getter method name

Declaration

public static String toGetter(final String field) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from   w w w. j a v  a  2s.co  m*/
     * Converts a field name into a getter method name.
     *
     * @param field the field name to convert
     * @return the getter method name
     */
    public static String toGetter(final String field) {
        return new StringBuilder("get").append(Character.toUpperCase(field.charAt(0)))
                .append(field.substring(1, field.length())).toString();
    }
}

Related

  1. toGetter(String fieldName)
  2. toGetter(String name)
  3. toGetterMethodName(String s)
  4. toGetterName(String name)