This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Java is zero indexed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Java is zero indexed" Watch "Java is zero indexed" New topic
Author

Java is zero indexed

Saibabaa Pragada
Ranch Hand

Joined: Oct 24, 2010
Posts: 162
Hi, I want to know the reason why Java arrays/Collections framework classes are zero-indexed. Please let me know.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4642
    
    5

Because the JLS says so.
http://java.sun.com/docs/books/jls/third_edition/html/arrays.html


luck, db
There are no new questions, but there may be new answers.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61456
    
  67

Most languages are.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Trivikram Kamat
Ranch Hand

Joined: Sep 26, 2010
Posts: 155
There is a mathematical reason behind it also:
Why the Array Index should start from 0


OCPJP6
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Java is zero indexed