I am beginner to Java, and I am reading up on Arrays from the tutorial at Oracle.
My question involves this code:
class ArrayCopyDemo {
public static void main(String[] args) {
char[] copyFrom = { 'd', 'e', 'c', 'a', 'f', 'f', 'e',
'i', 'n', 'a', 't', 'e', 'd' };
char[] copyTo = new char[7];
System.arraycopy(copyFrom, 2, copyTo, 0, 7);
System.out.println(new String(copyTo));
}
}
Specifically,
System.out.println(new String(copyTo));
What does new String(copyTo) exactly do, or rather why use new and String? What are they doing together? (I understand that they print out "caffein" but only in a very general sense.
Stringis just the name of a class.