0

I'm wondering how to start a Boolean array at 1 instead of 0.

so far the only thing i can think of is:

Boolean [] x = new Boolean[12]+ 1;
                                         or
	        Boolean [] x= new Boolean[12 + 1];

and the top one does not compile while the bottom one just makes the length to 13

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by masijade
0

What do you mean "start at one"? Do you mean that the first index should be 1 and not 0? Well, you can't. Java arrays (and the arrays of most other languages) index starting with 0. Make the array one longer and simply don't use the first index, or use indexes from 1 to array.length and simply subtract one when you actually index into the array.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.