-
Indexing starting with 1
Indexing in Java starts with 0.
I am working in an application where I need it to start with 1. I know this can be done by subtracting 1 simply. For instance, if I want to fetch the 3rd item, it will be:
Is there some pattern for this? I mean whats is the best way of achieving this.
-
If it's number (like 3 above) your approach is the simple and best approach. In variables (index variables) subtract it by one first before the array operation.
There is no best way though .. i would go over line by line making every thing correct..
-
Thanks roots.
nice signature :D
-
Roots is correct. In such a case do all the indexing operation with a temp value before doing the array operations.
-
Maybe you can wrap your array in a new class.