*
The moose likes Beginning Java and the fly likes Simple questions on arrays Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Simple questions on arrays" Watch "Simple questions on arrays" New topic
Author

Simple questions on arrays

David Duran
Ranch Hand

Joined: Feb 11, 2002
Posts: 122
Is the array a primitive datatype or is it an Object?
In terms of overhead, is an array much less than a List object?
Does an array have "member methods" or member fields other than ".length"?
Thanks
Sam Zou
Ranch Hand

Joined: Nov 18, 2002
Posts: 40
Answer 1 : the array is a primitive data type
Answer 2 : It depends what do you want to do. If you have a lot of insertion to do the List object may be a good idea, the insertion is simple. On the other hand, insertion in an array is a little bit more complicated, you have to manage yourself the insertion.

Answer 3: an array have more than the length member. It has the clone() method. And it inherit all the member and method of the Object class except the clone method.
I hope that the answer is clear enough. If you want more details information take a look at the java Specification.
Java Specification
YLT


Sam<p>"Life is difficult"<br /> -Scott Peck-</p>
David Duran
Ranch Hand

Joined: Feb 11, 2002
Posts: 122
Yves, thanks for the response and the link to the specification.
The array itself will already be filled, all I need to do are gets out of it so for my purpose the array is the better way to go over the List.
Dave Landers
Ranch Hand

Joined: Jul 24, 2002
Posts: 401
an array is an Object.
Prove it to yourself:
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8805
    
    5
David - Listen to Dave - an array is an object. Also, if when you are getting things back out of the array, if you're making a copy, then the array is fine. However - if you want to get something out and remove it from the array at the same time, ArrayList is the way to go.


Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Simple questions on arrays
 
Similar Threads
Object references in Array
JDK violating Encapsulation ?
basic question about array ?
member and local arrays
Assigning String[] to multiple variables