Java

Java String split() Method

Java String split() method returns a String array. It accepts string argument and treats it as regular expression. Then the string is split around the matches found. String split() Method Syntax There are two overloaded split() methods. public String[] split(String regex, int limit): The limit argument defines the result string array size. If the limit …

Java String split() Method Read More »

Java String equals() Method – Always Use This to Check String Equality

Java String equals() method compares this string to another object. Java String equals() Signature String equals() method signature is: The result is true if the argument is String having the same value as this string. For all other cases, it will return false. If we pass null argument, then the method will return false. Why …

Java String equals() Method – Always Use This to Check String Equality Read More »

Java String contains() Method Examples

Java String contains() method returns true if this string contains the given character sequence. Java String contains() method signature String contains() method signature is: public boolean contains(CharSequence s) There are three classes that implements CharSequence interface. String StringBuffer StringBuilder Important Points for contains() method This utility method was introduced in Java 1.5 It uses indexOf() …

Java String contains() Method Examples Read More »

Java String Pool

Java String Pool

Java String Pool is the special area in the heap memory to store string objects. There are two ways to create string objects. If we use double quotes to create a string object, it’s stored in the string pool. If we use the new operator to create a string, it’s created in the heap memory. …

Java String Pool Read More »