Previous


1.1 Changes: Array Copy Example

The last line of the arraycopy example uses a String constructor that creates a String object from an array of bytes. This constructor has been deprecated in favor of a new constructor. Here's the JDK 1.1 version of this example:
class ArrayCopyTest {
    public static void main(String[] args) {
        byte[] copyFrom = { 'd', 'e', 'c', 'a', 'f', 'f', 'e', 'i', 'n', 'a', 't', 'e', 'd' };
        byte[] copyTo = new byte[7];

        System.arraycopy(copyFrom, 2, copyTo, 0, 7);
	try {
            System.out.println(new String(copyTo, "latin1"));
	} catch (java.io.UnsupportedEncodingException e) {
            System.out.println(e.toString());
	}
    }
}
For details about this and other changes to the String class, see 1.1 Changes: String Class.


Previous