import org.apache.commons.lang.StringUtils; public class Example { public static void main(String[] args) { String str1 = ""; String str2 = null; System.out.println("String 1 is empty or null: " + StringUtils.isEmpty(str1)); System.out.println("String 2 is empty or null: " + StringUtils.isEmpty(str2)); } }
String 1 is empty or null: true String 2 is empty or null: true
import org.apache.commons.lang.StringUtils; public class Example { public static void main(String[] args) { String[] arr1 = {"hello", "world"}; String[] arr2 = {"foo", "bar"}; String joinResult = StringUtils.join(arr1, arr2, "-"); System.out.println("Joined string: " + joinResult); } }
Joined string: hello-world-foo-barIn these examples, we are using the org.apache.commons.lang StringUtils package library to perform string operations. The package provides many useful methods for working with strings in Java, making it easier and more efficient to manipulate strings.