We probably know that JS has a length function, and Java has the length function.
Cases
If the array is data[], then data.length
Code to copy code as follows
byte[] Phone =new byte[81]; Create an array of type byte with a length of 81
Phone[i]!=0 in phone[i]! The position of the array i is not equal to 0
Such as:
Code to copy code as follows
byte[] Phone =new byte[81]; Create an array of type byte with a length of 81
Phone[1]!=0 in phone[1]! The second value of the array is not equal to 0
Give an example to the landlord at the same time:
Code to copy code as follows
public class Studyarrary {
/**
* @param args
*/
public static void Main (string[] args) {
TODO auto-generated Method Stub
byte[] Phone =new byte[81]; Create an array of type byte with a length of 81
for (int a = 0; a < Bayi; a++)
Phone[a]= (Byte) A; The position of the array i is not equal to 0
for (int i = 0; i < Bayi; i++) {
if (phone[i]!=0) {
System.out.println ("phone[" +i+ "] is not equal to 0" + ", Phone" +i+ "is" +phone[i ");
}
Else
System.out.println ("phone[" +i+ "] equals 0" + ", Phone" +i+ "is" +phone[i ");
}
}
}
Length of a two-dimensional array
Code to copy code as follows
Public C (www.111cn.net) Lass lesson{
public static void Main (String [] args) {
How to declare a two-dimensional array:
data type [] Array name = new data type [length] [length];
data type [] Array name = {{123},{456}};
int [] [] num = new int [3][3]; Defines a two-dimensional array of three rows and three columns
Num[0][0] = 1; Assign a value to the first element of the first row
NUM[0][1] = 2; Assign a value to the second element of the first row
NUM[0][2] = 3; Assign a value to the third element of the first row
NUM[1][0] = 4; Assign a value to the first element in the second row
NUM[1][1] = 5; Assign a value to the second element of the second row
NUM[1][2] = 6; Assign a value to the third element of the second row
Num[2][0] = 7; Assign a value to the first element in the third row
NUM[2][1] = 8; Assign a value to the second element of the third row
NUM[2][2] = 9; Assign a value to the third element of the third row
for (int x = 0; x
for (int y = 0; y
System.out.print (Num[x][y]);
}
SYSTEM.OUT.PRINTLN ("/n");
}
}
}
Array value Arr[x][y] indicates that the value specified is the y column of row x.
When using a two-dimensional array object, note the length represented by
The array name is followed by a length (such as Arr.length), which refers to a few rows (row);
Specify the index with length (such as Arr[0].length), which is the number of elements owned by the row, that is, the column
From:http://www.111cn.net/jsp/java/46864.htm
Java get Array (two-dimensional array) Length instance program