RSS feed [root] /string /weblog /java



title search:


Wed Jan 06 20:49:46 HKT 2021


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

Wed Jan 06 20:49:46 HKT 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 20:13:52 HKT 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 00:09:52 HKT 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 09:57:03 HKT 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 11:47:12 HKT 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 17:04:49 HKT 2013 From /weblog/java/string


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

(google search) (amazon search)

Tue Nov 19 17:19:59 HKT 2013 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/

(google search) (amazon search)

Tue Oct 02 20:31:57 HKT 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 18:56:48 HKT 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 18:35:42 HKT 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)