Java has bounds checking for arraycopy and other functions built-in, therefore when trying to do the same thing as before we get: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: arraycopy: last source index 144 out of bounds for char[128] at java.base/java.lang.System.arraycopy(Native Method) at assignment2b.main(assignment2b.java:14)