How To Split String In Java

java-thumbnail

If you want to split the String value into the different parts based on the delimiter or regular expression, String class provides split() which does the job. It has two overloaded methods with the following syntax: split(String regex) – Splits this string around matches of the given regular expression. split(String regex, int limit) – Splits […]

Java String IndexOf Example

java-thumbnail

Java String class consist of methods for finding the index of occurrence in the given string literals. If there is no occurrence of the given characters, then it will return the “-1″.  The following are the few methods which is very useful to find the string values. indexOf(char) – Returns the index of the character […]

Java String Reverse using Recursion

java-thumbnail

This example shows how to reverse a string using the recursion technique. There are several ways to reverse a string one I have explained using the StringBuffer. Note: The best way is not to choose recursion technique for reversing the string. These concepts are usually used to teach students the recursion , not actual best practices […]

Java String Reverse using StringBuffer Example

java-thumbnail

In this example we shall show you how to reverse the string object by using the Java StringBuffer class. StringBuffer class has a method reverse() which is convenient for reversing a given string value. As it is define in the specification: Causes this character sequence to be replaced by the reverse of the sequence. If […]

Java String ReplaceAll Method Example

java-thumbnail

In this example we shall explain the replaceAll() method in the String class. With the replaceAll() method we can replace the whole or part of the string or character sequences. String objects are immutable and cannot be changed the value. When ever you change the value, new string object is created. This method also creates […]

Java String Intern Method Example

java-thumbnail

String manipulation is one of the most read and confused subject for the Java programmers. String literals are stored in the string pool where identical objects are pointing to the same reference. If you look at the below example, we have created the “JavaBeat” string using the literals and “new” operator. When we create the […]

Java – String matches() Method Example

java-thumbnail

This example shows how to use the String.matches() method for testing the regular expressions against any other strings. Using the regular expressions are very efficient to save lot of code for the validations. For example, you can use the pre-defined regular expression to validate the email address without extra code. Output

How To Convert String To Byte In Java?

java-thumbnail

This tutorial highlights the simple example to demonstrates how to convert a string object to the byte stream. We can simply use the getBytes() method in the string object to convert the string to bytes array. Lets look at the example program. Output

How To Convert Char To String In Java?

java-thumbnail

This post highlights a simple example to demonstrates how to convert a char datatype to a string object. Lets look at the example program. Output

Close
Please support the site
By clicking any of these buttons you help our site to get better