This content has been marked as final. Show 5 replies
There's no difference between capacity and number of elements in an array.
That array has ten elements. They all have a value. At the moment of creation the value will be 0/false/null as appropriate for the type of the elements.
int arr = new int;
If you want to know which elements have been explicitly set, you'll have to either keep a separate counter or bitmask, or initialize them all to some invalid value such as null or -1, if such value exists.
hmm ok thanks
is there a way i can set the capacity of an int array after i have initialised it?
is there a way i can set the capacity of an int arrayArrays don't have a capacity, they have a length. If you mean can you change the length of the array after initialization, then no, you can only create a new array with a new length.
after i have initialised it?
Have you looking into Sun's Graphics tutorial? http://java.sun.com/docs/books/tutorial/2d/index.html
One way to represent a polygon is to use GeneralPath:
You don't need to predeclare any arrays to use it.