Basic Java for Testers | Ch-4 | Arrays in Java

Reading Time : 5 minutes
Previous Chapter >>>> Basic Java for Testers | Ch-3 | Decision making in Java

A variable that can store multiple values of same datatype is called an Array in Java. An Array index starts at 0.
Syntax: DataType ArrayName []= New DataType [Size];

For example:
int iArray [] = new int [5];
int iArray [0] = 1;
int iArray [1] = 2;
int iArray [2] = 3;
int iArray [3] = 4;
int iArray [4] = 5;
Same Array can also be declared as:
int iArray[] = ['1','2','3','4','5']

Sample program using Arrays in Java:



Basic Java for Testers | Ch-4 | Arrays in Java Basic Java for Testers | Ch-4 | Arrays in Java Reviewed by Ishan Dev Shukl on March 24, 2018 Rating: 5

No comments:

Thanks a lot for your valuable Comment!

Powered by Blogger.