You are on page 1of 4

Variable can be used to store and manipulate values.

Only one value can be store in one variable at one


point of time. This means that in case you need to
store 20 values of the same type you need tot define
20 variables for holding those values. This problem
here is that a lot of memory is consumed for defining
an initializing.
Definition
An array is a special data store that can hold several items of a
single data type in contiguous memory locations

Array Types: 1)Single - Dimensional Array


2)Multi - Dimensional Array

Rate Names Rollno Mathes Science


58.00 manasa 1 65 99
1.5 karthika 2 99 54
2.7 swaroop 3 93 84
0.82 manoj 4 53 74
23.92 sowjanya 5 99 88
34.00 sandeep 5 99 50
Note :
An array variable is always
allocated memory on the stack

In Below syn the allocate memory to the array elements


dynamically.
Int a[] a=new int[10];
Int a[10];
Char ch[]={‘p’,’r’,’a’,’k’,’a’,’s’,’h’};
String str=new String[ch];
String str=“hello”;
String st=“Hello “+ “Good”+”Morning”;
String st2=st;
String st3 = new String(st1);

You might also like