Java String Pluralize pluralize(long val, String singular, String plural)

Here you can find the source of pluralize(long val, String singular, String plural)

Description

Determines whether the singular or plural version of a word should be used.

License

Open Source License

Parameter

Parameter Description
val Number to be tested.
singular Singular form of the value description.
plural Plural form of the value description.

Return

Singular form of the description if val is 1, the plural form otherwise.

Declaration

public static String pluralize(long val, String singular, String plural) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//from   www .  ja  v a2  s. c o m
     * Determines whether the singular or plural version of a word should be used.
     *
     * @param val Number to be tested.
     * @param singular Singular form of the value description.
     * @param plural Plural form of the value description.
     * @return Singular form of the description if {@code val} is 1, the plural form otherwise.
     */
    public static String pluralize(long val, String singular, String plural) {
        return (val == 1) ? singular : plural;
    }
}

Related

  1. pluralize(int count, String word)
  2. Pluralize(int quantity, String units)
  3. pluralize(int value, CharSequence singularForm, CharSequence pluralForm)
  4. pluralize(long count, String singularFormat, String pluralFormat)
  5. pluralize(long strictlyPositiveCount, String singular, String plural)
  6. pluralize(String base, int quantity)
  7. pluralize(String input)
  8. pluralize(String name)
  9. pluralize(String name)