Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Simple questions on arrays

 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
David Duran
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
an array is an Object.
Prove it to yourself:
 
author
Posts: 9034
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
If you settle for what they are giving you, you deserve what you get. Fight for this tiny ad!
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic