In Java there are multiple ways to manipulate both strings and numbers to work in a manner that is required. These methods can play a vital role in the business logic of a system.
For example: Say you have a list of 100 books and you need to provide the functionality to search for a book. Without being able to manipulate a String the user would always have to search for the full title of a book and ensure that every letter’s case, matches that of the title.
Java has built in methods to assist with just these kinds of situations.
Appending Number values to Strings.
Determine the total number of characters in a String.
How to alter the case of a String.
Finding the position of a character in a word/sentence.
Comparing 2 Strings to check for similarities.
Substituting new values into a String.
Splitting up sentences/words into multiple parts.
Remove empty spaces from the start and end of Strings.
Formatting Strings to a desired output. Example: for currency, converting 23.21 into R23.21.
On the other hand, being able to manipulate numbers is critical to most systems.
Convert negative values to positive values.
Rounding a number up or down.
Get the Highest/Lowest number, between 2 numbers.
Generate a Random number.
Get the Remainder/Modulus of 2 numbers.