Browse by Topic

Popular

Latest

Latest Java Posts

Diagram comparing StringBuilder and StringBuffer with thread safety and performance differences.
Java

Java StringBuilder vs StringBuffer: Which to Use

StringBuilder and StringBuffer in Java differ mainly in synchronization: StringBuilder is not synchronized and is usually faster; StringBuffer synchronizes its methods. Learn when to use each and why compound operations still need care.

StringBuilderStringBufferthread-safetyperformance
A visual comparison of an immutable String being copied on each concatenation versus a mutable StringBuilder buffer growing in place.
Java

Java String vs StringBuilder: When to Use Each

java string vs stringbuilder: Understand the real difference between Java String and StringBuilder: immutability, allocation behavior, compiler optimizations, thread s...

JavaStringBuilderString concatenationJava performance
Illustration of Java StringBuffer as a mutable character buffer with thread-safe operations, contrasting with immutable String.
Java

Java StringBuffer: Usage, Thread Safety, and Trade-offs

Understand Java's StringBuffer: what it is, how its core methods work, the thread-safety behavior of its synchronized operations, and when to prefer StringBuilder.

StringBufferStringBuilderJava stringsthread safety
Illustration of a StringBuilder assembling separate string parts into one unified string, contrasting with immutable String objects.
Java

Java StringBuilder: Efficient String Building

Understand how Java StringBuilder works, when it beats string concatenation, and how to avoid common performance pitfalls when building strings.

StringBuilderString ConcatenationJava PerformanceStringBuffer
Illustration of Java String lines() splitting a text into multiple lines, showing a stream of lines.
Java

Using Java String lines() to Split Text into Lines

Learn how to use Java's String.lines() method to split text into a stream of lines, including line terminator handling and practical examples.

JavaString APIStreamsText Processing
Illustration of Java string repeat concept with a repeated character sequence.
Java

Java String Repeat: Using String.repeat() and Alternatives

Learn how to repeat a string in Java using String.repeat(int) from Java 11, plus efficient alternatives for older Java versions.

JavaStringJava 11StringBuilder
Diagram showing a Java String being converted to a char array using the toCharArray() method.
Java

Java String to Char Array: Conversion and Tradeoffs

Convert a Java String to a char array with toCharArray() or charAt(). See how immutability, performance, and Unicode handling affect which approach to use.

JavaStringchar arraytoCharArray
Diagram showing conversion of a character array to a Java String object.
Java

Java Char Array to String: Conversion Methods

Learn how to convert a char array to a String in Java using new String(char[]), String.valueOf(), and StringBuilder, with notes on performance, mutability, and common pitfalls.

JavaString conversionchar arrayStringBuilder
Diagram showing Java String.valueOf converting a primitive int and a null object to string representations.
Java

Java String.valueOf: Converting Values to Strings

Learn how Java String.valueOf converts primitives and objects to strings, how its null handling works, and when to prefer it over other conversion methods.

JavaStringType ConversionNull Handling
Illustration of a Java string template with placeholders being filled by values, representing the formatted method.
Java

Java Formatted Method: String.format, Formatter, and String.formatted

Learn how to format strings in Java with String.format, Formatter, and String.formatted, including format specifiers, locale-aware output, and common pitfalls.

String.formatJava FormatterprintfString formatting