Java strings - null terminated

Java Conceptuel Diagram


Java strings are not terminated with a null characters as in C or C++.

However, when working with Jdbc, you can get Java String that are Null terminated.


// By getting the bytes, the null character goes away
// Character nullCharacter = '\u0000';
byte[] bytes = stringWithNullTermination.getBytes();
Charset charSet = Charset.forName("UTF-8");
stringWithoutNullTermination = new String(bytes , 0, bytes.length, charSet);

Documentation / Reference

Share this page:
Follow us:
Task Runner