Here you can find the source of pluralize(int count, String single)
public static String pluralize(int count, String single)
//package com.java2s; /******************************************************************************* * Copyright (c) 2012 Google, Inc.//from w w w .j ava2 s. c om * 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: * Google, Inc. - initial API and implementation *******************************************************************************/ import java.text.NumberFormat; public class Main { /** * Return the count and the quantity label as a properly pluralized string. * I.e. (5, "item") ==> "5 items". * <p/> * */ public static String pluralize(int count, String single) { if (count == 1) { return NumberFormat.getNumberInstance().format(count) + " " + single; } else { return NumberFormat.getNumberInstance().format(count) + " " + single + "s"; } } }