Java String.regionMatches() Java Java String The method regionMatches() checks if two String regions are equal. Here are a few important points: ignoreCase specifies whether we should ignore the case of both Strings toffset determines the starting index of the first String other specifies the second String. ooffset specifies the starting… Continue Reading string-region-matches

Java String.contains() Java Java String The method contains() checks if a String contains another String. The method accepts a CharSequence. So, we can pass any of the implementing classes to it such as StringBuilder and StringBuffer. Available Signatures public boolean contains(CharSequence s) Example @Test public void whenCallContains_thenCorrect() { String s… Continue Reading string-contains

Java String.codePointAt() Java Java String The method codePointAt() takes an int as a parameter and returns the code point at the specified index. A code point is a decimal value that the character is given in the Unicode standard. Available Signatures public int codePointAt(int index) Example @Test public void whenCallCodePointAt_thenDecimalUnicodeReturned()… Continue Reading string-code-point-at

Java String.startsWith() Java Java String The method startsWith() is a convenience method that checks whether a String starts with another String. We can also pass the index of the first character to start checking from. Available Signatures public boolean startsWith(String prefix) public boolean startsWith(String prefix, int toffset) Example @Test public… Continue Reading string-starts-with

Java String.replaceAll() Java Java String The method replaceAll() replaces all occurrences of a String in another String. Available Signatures public String replaceAll(String regex, String replacement) Example @Test public void whenCallReplace_thenCorrect() { String s = “I learn Spanish”; assertEquals(“I learn French”, s.replaceAll(“Spanish”, “French”)); } Next » Java String.split() « Previous Java… Continue Reading string-replace-all

Java String.copyValueOf() Java Java String The method copyValueOf() converts a character array to a String with the same contents. This method is equivalent to valueOf(char[]). The offset represents the index of the first element to start copying from, and the count represents the number of elements to copy. Available Signatures… Continue Reading string-copy-value-of