Java String.concat() Java Java String The method concat() concatenates two Strings. Simply put, it connects them into a single String. If the length of the argument is 0, then the method simply returns the String object. Available Signatures public String concat(String str) Example @Test public void whenCallConcat_thenCorrect() { assertEquals(“elephant”, “elep”.concat(“hant”));… Continue Reading string-concat

Java String.isEmpty() Java Java String The method isEmpty() is a convenience method that checks if the size of a String is equal to zero. Available Signatures public boolean isEmpty() Example @Test public void whenCallIsEmpty_thenCorrect() { String s1 = “”; assertTrue(s1.isEmpty()); } Next » Java String.lastIndexOf() « Previous Java String.intern()

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