Java String Constant Pool

Learn about String class in Java, the motivation behind making it immutable and the whole idea about String constant pool. We will see how memory …

Java String intern() method example

Last Updated:

The Java String intern() return the reference of a equal string literal present in string pool. String literals are automaically interned in Java.

Java String contains() method example

Last Updated:

The Java String contains() searches a substring in the given string. It returns true if substring are found in this string otherwise returns false. 1. …

Java String toLowerCase() method example

Last Updated:

Java String toLowerCase() returns a string which is result of converting all characters in given string to lowercase. Convert string to lowercase in Java.

Java String toUpperCase() method example

Last Updated:

The Java String toUpperCase() returns a string which is result of converting all characters in given string to UPPERCASE. Read more: Java example capitalize the …

Java String split()

Last Updated:

The split()method in java.lang.String class returns a string array after it splits the given string around matches of a given the regular expression. In this …

Java String replaceAll() method example

Last Updated:

The Java String replaceAll() returns a string after it replaces each substring of that matches the given regular expression with the given replacement. 1. String …

Java String replaceFirst() method example

Last Updated:

The Java String replaceFirst() method replaces the first substring ‘regex’ found that matches the given argument substring (or regular expression) with the given replacement substring. …

Java String replace() method example

Last Updated:

The Java String replace() method replaces each substring of this string that matches the literal target substring. The matching process starts at index 0.

Java String concat() method example

Last Updated:

The Java String concat() method concatenates the method argument string to the end of string object. 1. String concat(String str) method Internally, Java creates a …

Java String substring()

Last Updated:

Java String substring() example. Learn to get substring of a string from given start index to end index. A valid index is between 0 and length of string.

Java String lastIndexOf() method example

Last Updated:

Java String lastIndexOf() method. It returns the last index of specified character or string as method argument. If argument is not found it returns -1.

Java String indexOf() method example

Last Updated:

The Java String indexOf() method returns the index of given character or string as method argument. If argument is not found in string, method returns -1. The index counter for a string starts from zero.

Java String hashCode() method example

Last Updated:

Java String hashCode() method returns the hash code for the String. Hash code value is used in hashing based collections like HashMap, HashTable etc. This …

Java String endsWith() method example

Last Updated:

Java String endsWith() method is used to check the suffix of the string. It verifies if given string ends with argument string or not. 1. …

Java String startsWith() example

Last Updated:

Java String startsWith() method check if a string starts with prefix argument string. does not accept regex as argument. null argument is also not allowed.

HowToDoInJava

A blog about Java and its related technologies, the best practices, algorithms, interview questions, scripting languages, and Python.