get Setter Method Name For Field - Java Reflection

Java examples for Reflection:Setter

Description

get Setter Method Name For Field

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        String fieldName = "java2s.com";
        System.out.println(getSetterMethodNameForField(fieldName));
    }//  ww  w  .ja  v  a 2  s.  c om

    public static String getSetterMethodNameForField(String fieldName) {
        return "set" + fieldName.substring(0, 1).toUpperCase()
                + fieldName.substring(1);
    }
}

Related Tutorials