Problem statement: How will you declare, initialize & traverse an array?
- class TestArray {
- 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;
- }
- }
No comments:
Post a Comment