Monday, June 25, 2018

How do you declare, instantiate, initialize and traverse an array?

Problem statement: How will you declare, initialize & traverse an array?
  1. class TestArray {
  2. public static void main(String args[]) {
  3. int a[] = new int[5];// declaration and instantiation.
  4. a[0] = 10;// initialization.
  5. a[1] = 20;
  6. a[2] = 70;
  7. a[3] = 40;
  8. a[4] = 50;
  9. }
  10. }

No comments:

Post a Comment

Blueprint for self-improvement

To learn faster: Make the process fun To understand yourself : Write To understand the world better : Read To build deeper connection : Lis...