Single dimensional array in Java

Following is a simple example of a single dimensional array.

Example

public class Tester {
   public static void main(String[] args) {
      double[] myList = {1.9, 2.9, 3.4, 3.5};
      // Print all the array elements
      for (double element: myList) {
         System.out.print(element + " ");
      }
   }
}

Output

1.9 2.9 3.4 3.5
Updated on: 2026-03-11T22:50:41+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements