• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Array

 
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author
Posts: 361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 326
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
author and iconoclast
Posts: 24206
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Something must be done about this. Let's start by reading this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic