Hi Look at the API document. Arrays (Java 2 Platform SE v1.4.2) I have two questions. 1. Why "arrycopy" function is defined in the System class instead of Array class. 2. Look at the "All classes" list in the API document. I do see entry for class - Array - Array (in italic) - Arrays My questions is, what is that means here, meaning, why Java desiger has to create so many Array class. and What is the difference. Thanks siva
Hi Siva, My answer to your first question, "Why should the System class be responsible for copying arrays?" is this. The copying of arrays is that type of utility functionality that might be needed anywhere. In my humble opinion, that type of behavior is well placed in the System class. My short answer to your second question, "What are these classes, Array, Arrays, etc.?" is this: They are part of the Reflection API's, as well as providing other useful behavior specific to arrays. In particular, as you can see in the JavaDoc for the Arrays class (in the java.util package), it provides sorting and searching capabilities for arrays. The Array class (in the java.lang.reflect package) provides static (aka class) methods to create arrays dynamically, "on-the-fly" as needed. Hope this helps. Regards, [ March 10, 2004: Message edited by: Howard Kushner ]
Howard Kushner<br />IBM Certified Enterprise Developer - WebSphere Studio Application Developer V5.0<br />IBM Certified Advanced System Administrator - WebSphere Application Server V5.0<br />IBM Certified Solution Developer - Web Services with WebSphere Studio V5.1<br /><a href="http://www.amazon.com/exec/obidos/tg/detail/-/1931182108/" target="_blank" rel="nofollow">Developing J2EE Applications with WebSphere Studio</a> my Certification Study Guide for IBM Test 287
1) This is a bit of a guess, but I believe efficient array copying involves copying a block of memory from here to there, memory is handled in a system dependant way, thus, array copying is a system dependant operation. 2) The API gives further details than just the names of objects...
The real answer to the first question is that java.lang.System has been part of the Java API since the very first release, and arraycopy() has always been located there; but java.util.Arrays wasn't added in JDK 1.2, several years later. Now, they could have added a copy() in Arrays, and deprecated System.arraycopy(), but they chose not to -- perhaps because then virtually every Java program in existence would be using a deprecated method!
If you click on the links for the names you listed, you will find out that Array (without italics) is a class in the java.lang.reflect package, Array (with italics) is an interface in the java.sql package, and Arrays is a class in the java.util package. The Java API gives plenty more details about when and how to use each of these. Layne