RSS feed [root] /weblog /java /string




login:

password:

title search:




 


Wed Jan 06 23:49:46 AEDT 2021

string



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

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

intern


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.

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6988220

String.intern in Java 7 and 8 - http://java-performance.info/string-intern-in-java-6-7-8/ http://java-performance.info[..]-intern-java-6-7-8-multithreaded-access/ http://java-performance.info/string-intern-java-7-8-part-3/

Suggestion of improving string decoding - https://cl4es.github.io/2021/02/23/Faster-Charset-Decoding.html

(google search) (amazon search)


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

construction


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

(google search) (amazon search)


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

substring


Substring no longer just change offset - http://www.javaadvent.com[..]hanges-to-stringsubstring-in-java-7.html

https://cl4es.github.io/2019/05/14/String-Concat-Redux.html

(google search) (amazon search)


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

regex


Introduction to a library which support faster regular expression processing: http://weblogs.java.net[..]ite/archive/2006/03/a_faster_java_r.html http://www.javaadvent.com[..]-expression-library-benchmarks-2015.html

Regex helper - https://github.com/VerbalExpressions/JavaVerbalExpressions

java-regular-expressions-cheat-sheet - https://zeroturnaround.com[..]abs/java-regular-expressions-cheat-sheet

(google search) (amazon search)


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

comparison


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

http://jroller.com[..]ingcomparator_sorting_strings_for_people

source: http://jroller.com/resources/t/tfenne/HumaneStringComparator.java

Switch comparison - http://java-performance.info/string-switch-performance/

(google search) (amazon search)


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

unicode


A common issue of Windows environment and the workaround - http://jroller.com/page/ff?entry=java_utf_8_bug_grief

Strange String issues in JVM languages, don't trust all string operations all the time! https://sites.google.com[..]/posts/strangestringissuesinjvmlanguages http://mortoray.com/2013/11/27/the-string-type-is-broken/

(google search) (amazon search)


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

alignment


Discussion of how to do string alignment - http://manycupsofcoffee.blogspot.com.au[..]va-implementation-of-optimal-string.html

(google search) (amazon search)


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

stringbuffer


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

(google search) (amazon search)


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

toString


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]

http://crazybob.org/2006/02/simple-tostring-hack.html

(google search) (amazon search)


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

length


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:
http://forum.java.sun.com/thread.jspa?threadID=671720

(google search) (amazon search)