Browse by Topic

Popular

Latest

Latest Java Posts

Diagram showing how Java String toUpperCase() converts lowercase characters to uppercase while preserving the original immutable string
Java

Java String toUpperCase(): Usage, Locale, and Edge Cases

Learn how Java's String.toUpperCase() works, why locale matters, and how to avoid common pitfalls with case conversion in production code.

javastringlocaleunicode
A visual comparison of Java's trim() and strip() methods, showing ASCII-only whitespace removal versus Unicode whitespace removal.
Java

Java trim vs strip: Key Differences Explained

Understand the difference between Java's trim() and strip() methods, including Unicode whitespace handling, performance, and when to use each.

Java StringUnicode whitespaceString manipulationJava 11
Illustration showing Java String.strip() removing Unicode whitespace characters from both ends of a string, contrasted with trim() leaving them in place.
Java

Java String strip: Removing Unicode Whitespace

java string strip: Learn how Java's String.strip() removes Unicode whitespace, how it differs from trim(), and when to use each method in practice.

javastring-manipulationunicodejava-11
Illustration of a Java String being trimmed of leading and trailing spaces, showing the trim() method concept.
Java

Java String trim: Remove Leading and Trailing Whitespace

Java's String.trim() removes leading and trailing ASCII whitespace. See how it works, its edge cases, and how it differs from strip() in Java 11+.

JavaStringwhitespacetrim
Illustration of a Java string with a backward arrow pointing to the last occurrence of a character, representing the lastIndexOf method.
Java

Java String lastIndexOf: Usage and Edge Cases

Learn how to use Java String lastIndexOf effectively: overloads, backward search behavior, fromIndex handling, edge cases, and performance considerations.

JavaStringlastIndexOfString search
Diagram showing a magnifying glass scanning along a horizontal string bar with a highlighted character position marker
Java

Java String indexOf: Usage and Edge Cases

Learn how Java's String.indexOf() searches for characters and substrings, returns -1 for missing matches, and handles overloads and edge cases.

String methodsindexOfJava stringssubstring search
Diagram showing a Java string ending with a suffix, illustrating the endsWith method check.
Java

Java String endsWith: Syntax, Edge Cases, Performance

Learn how Java's String.endsWith() method checks suffixes: syntax, case sensitivity, null and empty suffixes, case-insensitive alternatives, and performance tradeoffs.

javastringendsWithsuffix
Java code snippet showing a string being checked with startsWith, with a magnifying glass highlighting the prefix comparison.
Java

Java String startsWith: Syntax and Common Pitfalls

java string startswith: Learn how to use Java String startsWith for prefix checks, including offset, case sensitivity, edge cases, and performance considerations.

JavaStringstartsWithString Comparison
Illustration of a magnifying glass over a a Java string highlighting a substring match, representing the contains method.
Java

Java String Contains: Checking Substrings Safely

Check for substrings in Java with String.contains: understand null and empty arguments, case sensitivity, and when to use indexOf or matches instead.

String.containssubringindexOfcase-insensitive
An illustration of a Java string splitting into two paths, one for literal replacement and one for regex pattern matching
Java

Java replace vs replaceAll: Literal Text vs Regex

Java's replace() matches literal text, while replaceAll() takes a regex. Includes replacement-string escaping, Matcher.quoteReplacement(), Pattern.quote(), and precompiling patterns.

Java StringRegexString ManipulationPattern Matching