This example demonstrates various string operations in Java. Note that while most operations are similar to their counterparts, there are some differences:
Java uses methods on the String object instead of functions in a separate package.
Some method names are slightly different (e.g., startsWith instead of HasPrefix).
Java doesn’t have a built-in Count method, so we implemented our own.
The Replace method in Java replaces all occurrences by default, while ReplaceFirst replaces only the first occurrence.
These examples give you a taste of Java’s string manipulation capabilities. For more detailed information, refer to the official Java String API documentation.