008-005-009

Array Printer Program

Easy

Problem Description

array Printer Program

In this problem, you will create a program that passes an int array to a printArray() method and displays each element on a separate line to standard output.

Learning Objective: Understand how to pass reference types (arrays) as method arguments

Overview

Create a program that passes an array to a method and displays its elements. Learn the basics of reference type arguments.

Specifications

  1. Define a printArray() method:

    • Receives an int array as an argument
    • Outputs each array element on a separate line
  2. In Main class:

    • Create an array with {10, 20, 30}
    • Call printArray() passing the array

Output Format

10
20
30

Hints

  • Specify array as method parameter like int[] numbers
  • Use a for loop to iterate through array elements

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?

Sign Up