When you create an array you need to know three things

If you know that you will need to mix data types or that you do not think there will be a maximum size then arrays can not be used. Arrays are always a fixed size and a single data type

A common mistake is to try and define a array as

Array names[] = new Array();

This is not correct. Array is a specific data structure within visual basic and technically it is a class not an array. If you try and use it you will have some very strange problems when you run your code. The first example would actually create a object of the data type Array. As you get on in programming you will understand why that is the case.

Arrays are defined as -

The data type must be stated twice. The left hand side creates a reference while the right hand side actually reserves the memory for the array. This is standard java so you get used to it! The size must be stated when the memory is reserverd. As arrays are static you can not change the size once the memory has been assigned.

You can also add values to the array when you define it.

int vals[] = {2,5,3,1,7,5};

next access array >>

 
Basics
Menu
Search