String and StringBuffer

regionMatches() and intern() String Java

The String class is rich with abundant methods used in coding. One of the methods is overloaded regionMatches() used to find the existence of a few characters of one string in another. Supported methods from String class. boolean regionMatches(int positionFirstString, String secondString, int positionSecondString, int num): Returns a boolean value of true if the region …

regionMatches() and intern() String Java Read More »

Search, Append and Insert StringBuffer Methods

Very often used many StringBuffer Methods are discussed with Examples and Screenshots in Simple terms for a Beginner. StringBuffer Methods for Searching characters The indexOf(), lastIndexOf() and charAt() methods existing in String class also exist in StringBuffer class. They can be used with StringBuffer object. The meaning of the methods is just same of String …

Search, Append and Insert StringBuffer Methods Read More »

StringBuffer substring Java Pass By Reference

StringBuffer substring Java Pass By Reference Many petty methods exist with StringBuffer like substring(), setLength() and trimToSize() etc. These methods are not much used in regular programming. public class MiscellaneousMethods { public static void main(String args[]) { // using substring(), to extract part of a string StringBuffer buffer1 = new StringBuffer(“TajMahal”); String s1 = buffer1.substring(3); …

StringBuffer substring Java Pass By Reference Read More »

Palindrome Delete Replace Reverse Java Example

Note: Palindrome Example is available in second page. 1. Deleting the Characters To delete characters from StringBuffer, two methods exist – deleteCharAt() and delete(). Supported methods from String class StringBuffer deleteCharAt(int pos): Delete the character in the StringBuffer at the specified index number, pos. StringBuffer delete(int start, int end): Deletes all the characters in the …

Palindrome Delete Replace Reverse Java Example Read More »

Java String Find matching characters indexOf(), lastIndexOf()

To Java String find matching, we use three methods – overloaded indexOf() and lastIndexOf() and charAt(). Index numbers are given by the JVM implicitly to the characters in the string; the first character is given 0, the second one as 1 and so on. These index numbers are helpful in programming in searching operations. Following …

Java String Find matching characters indexOf(), lastIndexOf() Read More »

toUpperCase(), toLowerCase() and replace() String

Here, we do some miscellaneous operations on strings like converting a string from lowercase to uppercase or vice versa, removing unwanted prefix and suffix whitespaces and replacing a few characters with replace() String. Supported methods from String class. String toLowerCase(): Returns a new string containing all lowercase characters. All the uppercase characters are converted into …

toUpperCase(), toLowerCase() and replace() String Read More »