• Post Reply Bookmark Topic Watch Topic
  • New Topic

What does index mean in Java?  RSS feed

 
Phillip Larson
Ranch Hand
Posts: 31
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm writing a program and I'm a little bit confuse on what index does in Java. Can someone please tell me what index is used for in Java?

Here my code if you need it.



Thanks In Advance
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37513
554
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The index is the position in the array. So the first element is index 0. Which is "Tacos". The second element is index 1. Which is "Pizza". Etc
 
Phillip Larson
Ranch Hand
Posts: 31
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the reply and I enjoy reading your book OCA 8.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The term "index" is not specific to Java. In programming languages, "index" usually refers to an ordinal number which is a number that defines a thing's position in a series of things. An array contains a series of same-typed elements, A String contains a series of characters, and a List contains a series of objects. You can use an index to reference any particular element, character, or object in these. In Java, index values are usually 0-based. That is, the first item in a series has an index of 0 and the last item has an index of (length - 1) where length is the total number of items in the series.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!