JavaDevNotes.com

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.

Java Left Pad String With Zeros Examples

Here are some example Java codes on how to Left Pad String With Zeroes to guarantee the length of a String. For example, if there are only 3 characters in a String and we wish to have it 10 characters long, we need to pad 7 zeroes to the left of the String.

Java Integer To Fixed Length String Examples

There are cases when we need to Convert a Java Integer To Fixed Length String. The logic should append a certain character, usually blank or zero, to fill the missing characters when the number of digits is less than the required number of characters.

Java String Split Limit Examples

The split method of the Java String class splits the given string into substrings given a delimiter. The result is an array of String. We may specify the maximum number of items returned by using specifying the limit. Java String Split Limit examples will be shown below.

Java Split String Into Array Of Integers Example

The String.split() method splits a String into an array of substrings given a specific delimiter. If we know that each substring represents a number or an integer, we may prefer to convert the output of String.split() into an array of integer.

Java Split String Into ArrayList Examples

The split() method of the String class splits a String into an array of substrings given a specific delimiter. Here are examples on how to convert the result of the Split Method into an ArrayList.

Java String Split Count Examples

The String.split() method splits a String into an array of substrings given a specific delimiter. Here are examples on how to know the number of substring created from the split.

Java String Split Newline Examples

It is common that we wish to Split a Java String using new line as delimiter. This usually happens when we load the contents of a text document to a String and we wish to break it line by ...