Limit an integer to certain number of digits and suffix '+' I am having a problem describing what the following code does. Below is my attempt at its javadoc.

/**
 * Convert an integer so that the notion of its size fits within a certain number digits.
 * e.g.
 * Fit 123 to 2 digits -&gt; 99+
 * @param in The integer
 * @param order The order of magnitude to fit it in.
 * @return The 'countified' String.
 */
public static String countify(int in, int order) {
    final int max = (int) Math.pow(10, order);

    if (in &gt;= max) {
        return String.valueOf(max - 1) + "+";
    } else  {
        return String.valueOf(in);
    }
}


The idea is simple enough. For any value greater than 10^order it returns 10^order - 1 plus a + (e.g. 123, with order 2 becomes 99+), else it returns the number itself. How do I better describe  it? Thanks!
Use less powerful language constructs

You use if and else

if (in &gt;= max) {
    return String.valueOf(max - 1) + "+";
} else  {
    return String.valueOf(in);
}


Using if and else duplicates return String.valueOf

Here the ternary operator comes to the rescue. It looks hard but really is very easy to use.

condition ? a : b


If condition is true, than a, else b. As easy as that.

You can now write return String.valueOf just one time:

return String.valueOf(in &gt;= max ? (max - 1) + "+" : in)