File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 4523
    
    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: 60053
    
  65

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java is zero indexed
 
Similar Threads
when java is 0 indexed
java.util.Calendar or GregorianCalendar
Empty Array.
SomeClass[] xyz = new SomeClass[10]();
related to best practice