Home / Programs / Basic programming of array using Java
🚀 Programming Example

Basic programming of array using Java

👁 1,248 Views
💻 Practical Program
📘 Step Learning
Basic programming of array

📌 Information & Algorithm

This Java program demonstrates the creation and usage of an array. It initializes a double array myList with 4 values and uses a for loop to iterate over the array elements. During each loop iteration, the program prints the value at the current index.

The key components are:

  • Array Declaration: double[] myList = {3.9, 5.9, 22.4, 31.5};
  • Loop: Iterates through the array using the index i.
  • Output: Each array element is printed with System.out.println().

💻 Program Code

public class ArrayExample {

   public static void main(String[] args) {
      double[] myList = {3.9, 5.9, 22.4, 31.5};

      // Print all the array elements
      for (int i = 0; i < myList.length; i++) {
         System.out.println(myList[i] + " ");
      }

   }
}
                        

🖥 Program Output

3.9
5.9
22.4
31.5
Press any key to continue . . .
                            

📘 Explanation

This is a basic programming of array
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.