Skip to main content
deleted 74 characters in body
Source Link
Gabe
  • 312
  • 1
  • 5

I would use Java's built-in message formatting method, MessageFormat. It has a means to select different text choices based on a number:

public String toAlbumSongCount() {      
    final int albumCount = albumCount();
    final int songCount = songCount();
    return MessageFormat.format(
        "{0,number} {0,choice,1#album|1<albums},{1,number} {1,choice,1#song|1<songs}",
        albumCount(), // parameter 0
        songCount()); // parameter 1
}

I would use Java's built-in message formatting method, MessageFormat. It has a means to select different text choices based on a number:

public String toAlbumSongCount() {      
    final int albumCount = albumCount();
    final int songCount = songCount();
    return MessageFormat.format(
        "{0,number} {0,choice,1#album|1<albums},{1,number} {1,choice,1#song|1<songs}",
        albumCount, // parameter 0
        songCount); // parameter 1
}

I would use Java's built-in message formatting method, MessageFormat. It has a means to select different text choices based on a number:

public String toAlbumSongCount() {      
    return MessageFormat.format(
        "{0,number} {0,choice,1#album|1<albums},{1,number} {1,choice,1#song|1<songs}",
        albumCount(), // parameter 0
        songCount()); // parameter 1
}
Source Link
Gabe
  • 312
  • 1
  • 5

I would use Java's built-in message formatting method, MessageFormat. It has a means to select different text choices based on a number:

public String toAlbumSongCount() {      
    final int albumCount = albumCount();
    final int songCount = songCount();
    return MessageFormat.format(
        "{0,number} {0,choice,1#album|1<albums},{1,number} {1,choice,1#song|1<songs}",
        albumCount, // parameter 0
        songCount); // parameter 1
}