Then learn java program will continue to start Array is a variable declaration in the java program, which makes it easier for a programmer in a program.
ARRAY -> Array is a solution to declare a number of variable appropriately. Use an array of variables to save time pronouncing the name variable. Array variable is a number of variables with the same name.
Illustrasi Array:
Index data
notes: No.Indeks / beginning No.Element number 0 (zero) and end n-1 where n = number of data.
DECLARE VARIABLE ARRAY
General form:
Data Type [] Variablename [= new datatype [number of elements]]
Some way declare an array variable:
1. Without mentioning some of the required number of elements
int [] numbers;
In the example above variable number can not be (fill in) before a number of elements or ordered before the reservation. So that should be written under the command like this:
number = new int [5];
2. With the number of elements that are required
int [] numbers = new int [5];
Keep in mind, how the above data is done manually with the input one-one.
3. With the automatic method
number of elements not explicitly shown can still be seen from the data that is defined sacara regularly.
int number = (3,5,7,1,10);
Calculating Number of Array Elements:
Java provides a function or method to calculate the number of elements that have a variable array in the function "length".
WRITING FORMAT AS NEXT
Name_Variable_ArrayLength
example
System.out.println ( "number of elements in the array variable is a number:" + number.length);
Sample Program initialisation-Element Array Element
Output or Results
notes : picture on the side of the program is the result of the above, where the above program using JCreator pro (JAVA)
Sunday, August 16, 2009
11:01 PM
Java home
No comments
0 comments:
Post a Comment