RSS feed [root] /weblog /java /string



title search:


Wed Jan 06 23:49:46 AEDT 2021


(google search) (amazon search)
download zip of files only

Wed Feb 24 14:49:26 AEDT 2021 From /weblog/java/string


String.intern() is designed for constant strings, it's implemented in C/C++ in the hotspot core code, and it has a fixed-size hashmap of around 20K entries and if more than this number of strings are interned, the performance degrades linearly since there are hash collisions and the code has to search down linked lists.

String.intern in Java 7 and 8 -[..]-intern-java-6-7-8-multithreaded-access/

Suggestion of improving string decoding -

(google search) (amazon search)

Wed Jan 06 23:49:46 AEDT 2021 From /weblog/java/string


Java's String.repeat Method in Action: Building PreparedStatement with Dynamic Number of Parameters -[..]k11-string-repeat-preparedstatement.html

(google search) (amazon search)

Mon Jun 10 22:13:52 AEST 2019 From /weblog/java/string


Substring no longer just change offset -[..]hanges-to-stringsubstring-in-java-7.html

(google search) (amazon search)

Sun Mar 26 03:09:52 AEDT 2017 From /weblog/java/string


Introduction to a library which support faster regular expression processing:[..]ite/archive/2006/03/a_faster_java_r.html[..]-expression-library-benchmarks-2015.html

Regex helper -

java-regular-expressions-cheat-sheet -[..]abs/java-regular-expressions-cheat-sheet

(google search) (amazon search)

Wed Jul 23 11:57:03 AEST 2014 From /weblog/java/string


Better sorting should do 2 things:
1) case insensitive
2) aware of numbers in the file names. So File2 comes after File1 (obviously) but before File10[..]ingcomparator_sorting_strings_for_people


Switch comparison -

(google search) (amazon search)

Mon Dec 02 14:47:12 AEDT 2013 From /weblog/java/string


A common issue of Windows environment and the workaround -

Strange String issues in JVM languages, don't trust all string operations all the time![..]/posts/strangestringissuesinjvmlanguages

(google search) (amazon search)

Fri Nov 22 20:04:49 AEDT 2013 From /weblog/java/string


Discussion of how to do string alignment -[..]va-implementation-of-optimal-string.html

(google search) (amazon search)

Tue Oct 02 22:31:57 AEST 2012 From /weblog/java/string


In core libraries like StringBuffer we should prefer the lesser evil of code duplication to the loss of performance. -[..]lder%7D-are-inconsistent-td34479926.html

(google search) (amazon search)

Tue Feb 07 21:56:48 AEDT 2006 From /weblog/java/string


Nice and simple toString():

public String toString() {

return MyClass.class.getSimpleName()

+ new LinkedHashMap() {{

put("foo", foo);

put("bar", bar);

put("tee", tee);



Results in:

MyClass[foo: fooValue, bar: barValue, tee: teeValue]

(google search) (amazon search)

Tue Nov 08 21:35:42 AEDT 2005 From /weblog/java/string


Surprisingly, String length more complicate than we excepted. A char is not necessarily a complete character, so if you need to know the character length, you need to use codePointCount method

int charLen = myString.length();
int characterLen = myString.codePointCount(0, charLen);

However, if you use UTF-8 encoding, string.length() will work as expected.

More detail see:

(google search) (amazon search)