strings
27 tutorials tagged “strings”.
- Where the String Pool LivesSince Java 7, pooled strings live on the heap and the JVM keeps a table of references to them. Learn how to see the pool and how it is garbage collected.
- Character Class Methods in JavaCheck and convert single characters with the Character class: letters, digits, case and white space, plus why char is secretly a number.
- Character Encoding and Charsets in JavaHow text becomes bytes: Unicode, UTF-8 and other charsets, why mojibake like naïve appears, and how to always choose the charset explicitly.
- Regular Expressions in JavaSearch text by pattern instead of exact words: Pattern and Matcher, find vs matches, positions and results, and why patterns are compiled once.
- Strings in JavaWhat a String really is, the ways to create one, and why Java keeps a String pool so identical text is stored only once.
- Modern String Methods in JavaNewer String methods that save real effort: isBlank, strip, repeat, lines, formatted, indent and transform, and why strip beats trim.
- Integer.parseInt() vs Integer.valueOf()Convert text to numbers: parseInt returns an int, valueOf returns a cached Integer. Radix, signs, the NumberFormatException messages, and which to choose.
- Regex with String MethodsUse regex straight from String: matches, split, replaceAll and replaceFirst, their surprises with dots and dollar signs, and when to precompile.
- How to Reverse a String in JavaFour ways to reverse a string: StringBuilder.reverse, a two-pointer swap, a backward loop and recursion, with what each costs and the emoji trap.
- String Comparison in JavaCompare strings correctly: == vs equals vs equalsIgnoreCase vs compareTo, why == fails, null-safe comparisons, and how sorting order is decided.