Array

 Array is a linear data structure. 

 Linear data structure is the organisation of data in a sequencial manner.  

 Array works in index methodology.

 Types of Array-

1. Static Array- In static array subscript is required to declare the array.

like- 

a[5];

2. Dynamic Array- In dynamic array the subscript value is not given.

like- 

int[] a = {12,23,34,4,55};

int a[] = {10,39,47,58,59}; 


User Input- 

//Declaring the array

int[] a = new int[no_of_elements];

Ex-

import java.util.Scanner;

public class Test

{

public static void main(String args[])

{

Scanner s1 = new Scanner(System.in);

int[] a = new int[7];

int i;//i is a counter variable 

for(i=0;i<a.length;i++)

a[i] = s1.nextInt();

}

for(i=0;i<a.length;i++) 

{

System.out.println(a[i]);

}

}

}  


 



Comments