--- _db_id: 124 content_type: topic ready: true title: Strings and numbers in Java --- 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. ## Manipulating Strings - [Concatenating Strings](https://www.javatpoint.com/string-concatenation-in-java). - [Appending](https://www.tutorialspoint.com/concatenate-string-to-an-int-value-in-java) Number values to Strings. - [Determine the total](https://www.javatpoint.com/java-string-length) number of characters in a String. - How to alter the [case](https://beginnersbook.com/2013/12/java-string-tolowercase-method-example/) of a String. - Finding the [position](https://www.tutorialspoint.com/Difference-between-charAt-and-indexOf-in-Java) of a character in a word/sentence. - [Comparing](https://www.geeksforgeeks.org/compare-two-strings-in-java/) 2 Strings to check for similarities. - [Substituting](https://www.javatpoint.com/java-string-replace) new values into a String. - [Splitting up](https://www.geeksforgeeks.org/split-string-java-examples/) sentences/words into multiple parts. - [Remove empty spaces](https://www.journaldev.com/33291/java-string-trim-method-examples) from the start and end of Strings. - [Formatting](https://dzone.com/articles/java-string-format-examples) 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. ## Manipulating Numbers - [Convert](https://www.tutorialspoint.com/java/lang/math_abs_int.htm) negative values to positive values. - [Rounding](https://www.javacodex.com/Math-Examples/Floor-and-Ceiling-Example) a number up or down. - Get the [Highest/Lowest](https://www.geeksforgeeks.org/java-math-max-method-examples/) number, between 2 numbers. - [Calculate X to the power of Y](https://www.geeksforgeeks.org/math-pow-method-in-java-with-example/). - Generate a [Random](https://www.geeksforgeeks.org/java-math-random-method-examples/) number. - Get the [Remainder/Modulus](http://www.cafeaulait.org/course/week2/15.html) of 2 numbers.