943,931 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 761
  • Java RSS
Oct 8th, 2007
0

Arrays

Expand Post »
Hi all,

Out of curiosity, why does an array start with 0 instead of 1? It would cut down of alot of confusion if it did.

Thanks
Similar Threads
Reputation Points: 8
Solved Threads: 0
Junior Poster
KimJack is offline Offline
114 posts
since Apr 2006
Oct 8th, 2007
0

Re: Arrays

You not gone be first asking such a question. If you google in most programmming forums such a question been asked. I do not know the answer but I presume it is from past times of old languages like assembler, pascal etc where programer besides of creating program had to keep an eye on memory management. All computer data are digitally organized(ie in binary) even today 0- 0000, 1-0001, 2 0010, 3-0011...
It is said the C programming language actualy made zero array position widely used. Duno....
If you interested may want to read this document by Edsger W. Dijkstra called Why numbering should start at zero
Last edited by peter_budo; Oct 8th, 2007 at 8:07 pm.
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 873
Code tags enforcer
peter_budo is offline Offline
6,656 posts
since Dec 2004
Oct 8th, 2007
0

Re: Arrays

Just a stab in the dark, but I, too, think it's memory management. An array is represented in memory by a pointer to its first element. The index of the array can indicate the offset from the value of that pointer.
Last edited by cscgal; Oct 8th, 2007 at 8:50 pm.
Administrator
Staff Writer
Reputation Points: 1422
Solved Threads: 162
The Queen of DaniWeb
cscgal is offline Offline
13,645 posts
since Feb 2002
Oct 8th, 2007
0

Re: Arrays

Thanks cscgal. That makes alot of sense. Still would be nice if it started at 1 and used 0 as an offset instead.
Reputation Points: 8
Solved Threads: 0
Junior Poster
KimJack is offline Offline
114 posts
since Apr 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Java(sort/dsort)
Next Thread in Java Forum Timeline: Need Help for playing a Video file in Java Application





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC