Java String Contains Examples

It is a common scenario in programming when we wish to check if one String contains a specific substring. For example, we wish to test if the String "The quick brown fox" contains the substring "brown". The Java String class has a method contains() that can help with this case. Below are examples on how to use Java String's contains method.

Java Double To String Without Exponential Scientific Notation

When dealing with numbers that are not whole, the type double is usually used for convenience because it is primitive and has good precision. However, when a double variable is converted to String, most of the time the result is in exponential or scientific notation. Below are some examples on how to perform in Java the conversion from double to String without exponential or scientific notation.

Java Double To String 2 Decimal Places Examples

When dealing with double values in your application, it is sometimes required to convert the values into String. Below are examples on how to convert double to String in Java using two decimal places.

Java Array To String

Java objects have the toString() method to convert the instance to it's String representation. If you will try to invoke the toString() method of an Array, the result will be some weird String like [I@70f9f9d8. This does not seems logical, say for example you wish to write the String to logs. It is more useful to convert a Java Array to a String that gives human understandable results. Below are some examples on how to do that.

Java String Array Examples

A Java String Array is an object that holds a fixed number of String values. Arrays in general is a very useful and important data structure that can help solve many types of problems. It's simplicity on how to access contents through index makes it powerful yet user-friendly. Here are some examples on how to use String Array in Java.

Java String Replace Tutorial And Examples

The Java String replace method can be used to replace a character or a string sequence from an instance of a String, with a new value of character or a String sequence. This is very useful in problems that needs String manipulations. ...

Java Float To String 2 Decimal Places Examples

Float is one of the most basic data type in Java for representing numerical values with decimal places. A common situation is when we want to convert a float value to String. Below are some examples on how to convert float to String in Java using two decimal places.

Java Substring Examples

The substring method of String is very useful in Core Java Programming. It is a fundamental method in performing String manipulation. What it does is extract a sequence of characters from a String and return that as a new String object. This post will show examples on how to use the Java substring method.

Java Left Pad String Examples

Here are some example codes to pad a custom character to the left side of a String to achieve a target length.

Java Left Pad String With Spaces Examples

There are cases where we need to guarantee the width of a String. If the width is less than the target, we can pad the String to meet the required length. Here are some example Java codes on how to Left Pad String With Spaces to guarantee the length of a String.