Arrays

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Apr 2006
Posts: 114
Reputation: KimJack is an unknown quantity at this point 
Solved Threads: 0
KimJack KimJack is offline Offline
Junior Poster

Arrays

 
0
  #1
Oct 8th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,245
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 492
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: Arrays

 
0
  #2
Oct 8th, 2007
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.
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,054
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 128
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb

Re: Arrays

 
0
  #3
Oct 8th, 2007
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.
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/DaniWeb
And if you're interested in Internet marketing there is twitter.com/DaniWebAds
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 114
Reputation: KimJack is an unknown quantity at this point 
Solved Threads: 0
KimJack KimJack is offline Offline
Junior Poster

Re: Arrays

 
0
  #4
Oct 8th, 2007
Thanks cscgal. That makes alot of sense. Still would be nice if it started at 1 and used 0 as an offset instead.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC