Showing posts with label array. Show all posts
Showing posts with label array. Show all posts

Friday, August 28, 2009

2-dimensional array is a continuation of the 1-dimensional array in which the 2-dimensional array is a solution to resolve the java program error that can not be done with a 1-dimensional array is.

2 DIMENSIONAL ARRAY-> Lots of things that can not be solved with a 1-dimensional array. Examples: for applications such as matrix-shaped table where the table of metrics are appointed by both rows and columns in filling or taking data matrix. Thus necessary to solve the problem of 2-dimensional array.
Syntax
Datatype[] [] name.var [= new daattype [number of rows] [number of coloums]];

Some ways to access the array variable
is a way that is used to fill, and retrieve data into an array variable.

* Fill the data into 2-dimensional array of variables is done by mentioning No.Rows and No.Coloums of the element to be filled.
Syntax
Name_var [no_Rows] [no_Coloums] = data

* Importing data from 2-dimensional array used by No.Rows and No.Coloums mention of the array, which aims to save kesebuah variable or to print.
Syntax
Name_var = name_var [no_Rows] [no_Coloums]

click the image below for details

this is the introduction of an array, which has some differences from the array 1 and array 2. java program starts from the simple.

Sunday, August 16, 2009

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)

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Macys Printable Coupons