If you want to know size or length of array than use inbuilt in java function
Syntax:-
array_name.length
array_name is name of array
length is used to fined size/index value of the array. If you change number of element in array, length function not get effect.
The output of array_name.length is size of array
Note:-
# The output of array_name.length is always integer
# Array_name is variable
Example:-
class group{
public static void main(String argn[]){
int data [] = {45,87,124,78,127,2};
System.out.println("Index value of data array is "+data.length);
for(int i = 0; i < data.length; i++)
System.out.println(data[i]);
}
}
Output:-
Index value of data array is 6
45
87
124
78
127
2
Previous Code:-
Initialization of arrays
List Code:-
Java codes
Next Code:-
Enhanced for loop
Java Programs:-
List of Java Programs
Syntax:-
array_name.length
array_name is name of array
length is used to fined size/index value of the array. If you change number of element in array, length function not get effect.
The output of array_name.length is size of array
Note:-
# The output of array_name.length is always integer
# Array_name is variable
Example:-
class group{
public static void main(String argn[]){
int data [] = {45,87,124,78,127,2};
System.out.println("Index value of data array is "+data.length);
for(int i = 0; i < data.length; i++)
System.out.println(data[i]);
}
}
Output:-
Index value of data array is 6
45
87
124
78
127
2
Previous Code:-
Initialization of arrays
List Code:-
Java codes
Next Code:-
Enhanced for loop
Java Programs:-
List of Java Programs
thnx
ReplyDeletereally nice explanation for beginners thank you
ReplyDeletememe
DeleteThank you for the blog. Found it interesting and useful. Java is a general purpose, high-level, class-based and object-oriented programming language. And we provide Java training in Chennai at Fita.
ReplyDeleteThank you for the blog. Found it interesting and useful. Java is a general purpose, high-level, class-based and object-oriented programming language. And we provide Java training in Chennai at Fita.
ReplyDeleteIf you are looking for java ,hadoop ,spring hibernate training institute in chennai then candid training is the best place to learn.
ReplyDeleteCandid gives you best in class spring hibernate training with high quality and post training support, We provide you free demo session and candid promises the permanent trainer throughout your session and focus on more practical.