集册 Java实例教程 getter方法名称到Setter方法名称

getter方法名称到Setter方法名称

欢马劈雪     最近更新时间:2020-01-02 10:19:05

401
getter方法名称到Setter方法名称


//package com.nowjava;//来 自 N o w J a v a . c o m - 时代Java


public class Main {

    public static void main(String[] argv) throws Exception {

        String methodName = "nowjava.com";

        System.out.println(getter2Setter(methodName));

    }


    public static String getter2Setter(String methodName) {

        if (methodName.startsWith("get")) {

            return "s" + methodName.substring(1);

        } else if (methodName.startsWith("is")) {

            return "set" + methodName.substring(2);

        } else {
        /* 
        *来 自
         时代Java公众号 - nowjava.com
        */
展开阅读全文