• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java is zero indexed

 
Saibabaa Pragada
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I want to know the reason why Java arrays/Collections framework classes are zero-indexed. Please let me know.
 
Darryl Burke
Bartender
Posts: 5162
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because the JLS says so.
http://java.sun.com/docs/books/jls/third_edition/html/arrays.html
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65663
129
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most languages are.
 
Trivikram Kamat
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a mathematical reason behind it also:
Why the Array Index should start from 0
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!