Advertisement
TrashScrape

Access Array Elements

Nov 27th, 2021
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. class Main {
  2. public static void main(String[] args) {
  3.  
  4. // create an array
  5. int[] age = {12, 4, 5, 2, 5};
  6.  
  7. // access each array elements
  8. System.out.println("Accessing Elements of Array:");
  9. System.out.println("First Element: " + age[0]);
  10. System.out.println("Second Element: " + age[1]);
  11. System.out.println("Third Element: " + age[2]);
  12. System.out.println("Fourth Element: " + age[3]);
  13. System.out.println("Fifth Element: " + age[4]);
  14. }
  15. }
  16.  
  17.  
  18. https://www.programiz.com/java-programming/arrays
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement