Here you can find the source of getSetter(String s)
Parameter | Description |
---|---|
s | - |
public static String getSetter(String s)
//package com.java2s; /**/* w w w . j a va 2s.co m*/ * MVEL 2.0 * Copyright (C) 2007 The Codehaus * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import static java.lang.Character.toUpperCase; public class Main { /** * This new method 'slightly' outperforms the old method, it was * essentially a perfect example of me wasting my time and a * premature optimization. But what the hell... * * @param s - * @return String */ public static String getSetter(String s) { char[] chars = new char[s.length() + 3]; chars[0] = 's'; chars[1] = 'e'; chars[2] = 't'; chars[3] = toUpperCase(s.charAt(0)); for (int i = s.length() - 1; i != 0; i--) { chars[i + 3] = s.charAt(i); } return new String(chars); } }