Example of single dimensional java array
#Array_in_Java #array #java_array
Normally, array is a collection of similar type of elements that have contiguous memory location.
In java, array is an object the contains elements of similar data type. It is a data structure where we store similar elements. We can store only fixed elements in an array. Array is index based.
class B{
public static void main(String args[]){
int a[]=new int[5];//declaration and instantiation
a[0]=10;//initialization
a[1]=20;
a[2]=70;
a[3]=40;
a[4]=50;
for(int i=0 ;i < a.length;i++)
System.out.println(a[i]);
}
}
Creating one dimensional array and run code using java command line .
Hope you like it subscribe our instagram and facebook account for more update.