AI May 15, 2023 5 min read

Module 14: Arrays

BR

Bhargava Ram Pantina

Web Developer & AI Enthusiast

📚 What is an Array?

An array is a collection of similar types of data stored in a contiguous memory location. Arrays are used to store multiple values in a single variable, instead of declaring separate variables for each value.

🔢 Declaring and Initializing Arrays

                    int[] numbers = new int[5]; // Declaration with size
                    numbers[0] = 10;
                    numbers[1] = 20;
                    numbers[2] = 30;
                    numbers[3] = 40;
                    numbers[4] = 50;
                    
                    // Or directly initialize
                    int[] scores = {90, 85, 70, 60};
                    

🔁 Traversing Arrays

                    for (int i = 0; i < scores.length; i++) {
                        System.out.println("Score: " + scores[i]);
                    }
                    
                    // Enhanced for loop
                    for (int score : scores) {
                        System.out.println("Score: " + score);
                    }
                    

📦 Multidimensional Arrays

                    int[][] matrix = {
                      {1, 2},
                      {3, 4},
                      {5, 6}
                    };
                    
                    for (int i = 0; i < matrix.length; i++) {
                      for (int j = 0; j < matrix[i].length; j++) {
                        System.out.print(matrix[i][j] + " ");
                      }
                      System.out.println();
                    }
                    
Artificial Intelligence Web Development Technology Trends Machine Learning UX Design

Share this article

About the Author

BR

Bhargava Ram Pantina

Bhargava Ram is a web developer and AI enthusiast with over 8 years of experience in the tech industry. He specializes in creating innovative web solutions that leverage the latest technologies to solve real-world problems.

Related Articles

AI Mar 15, 2023

Implementing ChatGPT in Your Web Application: A Step-by-Step Tutorial

Learn how to integrate OpenAI's ChatGPT into your web application to create intelligent chatbots and enhance user interactions.

Read More →
Web Development Apr 22, 2023

Building Accessible Web Forms: A Complete Guide

Learn how to create web forms that are accessible to all users, including those with disabilities. This comprehensive guide covers ARIA attributes, keyboard navigation, and more.

Read More →

Subscribe to My Newsletter

Get the latest articles and resources delivered straight to your inbox.

No spam, just valuable content. Unsubscribe anytime.