Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Returning an Array from a Method

public class ReturnMethod {
    static int[] ReturnArrayFromMethod() {
        // declaring array and initialized
        // variable arrayRefVar.
        int[] result = { 1, 2, 3, 4, 5 };
        return result;
    }

    public static void main(String[] args) {
        // Returning an Array from a Method
        int[] A = ReturnArrayFromMethod();
        for (int i = 0; i < A.length; i++) {
            System.out.println(A[i]);
        }
    }
}
 
PREVIOUS NEXT
Tagged: #Returning #Array #Method
ADD COMMENT
Topic
Name
9+1 =