Name: Reena Priyadharshini.R Roll No: 17BCC039 Subject: Java Date: 4.7.18
Name: Reena Priyadharshini.R Roll No: 17BCC039 Subject: Java Date: 4.7.18
ROLL NO : 17BCC039
SUBJECT : JAVA
DATE : 4.7.18
Arrays
Arrays in Java are homogeneous data structures implemented in Java as objects. Arrays
store one or more values of a specific data type and provide indexed access to store the same. A
specific element in an array is accessed by its index. Arrays offer a convenient means of
grouping related information.
Example:-
Arrays can be initialized when they are declared. The array will automatically be created
large enough to hold the number of elements you specify in the array initializer. There is no need
to use new.Now, let us see how we can implement this.
General Form of Java Array Initialization
1 class MyArray{
2
3 public static voide main(String args[]){
4
5 int month_days[ ] = {31,28,31,30,31,30,31,30,31,30,31};
6
7 System.out.println("April has " + month+days[3] + "days.");
8
9 }
10
11 }