Here you can find the source of plural(String singular)
public static String plural(String singular)
//package com.java2s; /******************************************************************************* * Copyright (c) 2010 Oobium, Inc./*from w ww . j av a2 s.c o m*/ * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Jeremy Dowdall <jeremy@oobium.com> - initial API and implementation ******************************************************************************/ public class Main { public static String plural(String singular) { if (singular == null || singular.length() == 0) { return singular; } if (singular.equalsIgnoreCase("person")) { return singular.charAt(0) + "eople"; } else if (singular.equalsIgnoreCase("child")) { return singular.charAt(0) + "hildren"; } else if (singular.equalsIgnoreCase("alumnus")) { return singular.charAt(0) + "lumni"; } else if ('y' == singular.charAt(singular.length() - 1)) { if (singular.length() > 1) { switch (singular.charAt(singular.length() - 2)) { case 'a': case 'e': case 'i': case 'o': case 'u': break; default: return singular.substring(0, singular.length() - 1) + "ies"; } } } else if ('s' == singular.charAt(singular.length() - 1)) { return singular + "es"; } else if (singular.endsWith("ch")) { return singular + "es"; } return singular + "s"; } }