So I’m going to show a way in which we can pluralize words according to the grammatical rules of the English language. For this we can use the method endsWith(). This method can be used with the strings and it’s possible to check the end of the string to perform the actions according to the situation.

The first verification is very important. We need to know if the word is already in plural mode, if yes: we must do nothing.

The second verification, as the words end we can do the changes. So for this I used another method called substring, this method returns the part of the word and we can use the part we need.

--

--

Rômulo Leitão

Rômulo Leitão

Olá mundo! I have written articles about technology, more specifically on Software Development. Born in Ceara, state of Brazil. Lives in Sherbrooke, Canada.