Will the result of String.getBytes() ever contain zeros?
<p>I have tried numerous Strings with random characters, and except empty string "", their .getBytes() byte arrays seem to never contain any 0 values (like {123, -23, 54, 0, -92}).</p>

<p>Is it always the case that their .getBytes() byte arrays always contain no nero except an empty string?</p>

<p>Edit: the previous test code is as follows. Now I learned that in Java 8 the result seems always "contains no 0" if the String is made up of (char) random.nextInt(65535) + 1; and "contains 0" if the String contains (char) 0. </p>

<pre><code>private static String randomString(int length){
    Random random = new Random();

    char[] chars = new char[length];
    for (int i = 0; i &lt; length; i++){
        int integer = random.nextInt(65535) + 1;
        chars[i] = (char) (integer);
    }
    return new String(chars);
}

public static void main(String[] args) throws Exception {

    for (int i = 1; i &lt; 100000; i++){
        String s1 = randomString(10);
        byte[] bytes = s1.getBytes();
        for (byte b : bytes) {
            if (b == 0){
                System.out.println("contains 0");
                System.exit(0);
            }
        }
    }
    System.out.println("contains no 0");

}
</code></pre>