Answers for "how to return array in java"

11

how do you make a method that returns an array java

public static int[] numbers()  
{  
int[] arr={5,6,7,8,9};  //initializing array  
return arr;  
}
Posted by: Guest on March-11-2020
0

how to return array in java

import java.util.Arrays;

public class trial1{

    public static void main(String[] args){
        int[] B = numbers();
        System.out.println(Arrays.toString(B));
    }

    public static int[] numbers(){
        int[] A = {1,2,3};
        return A;
    }
}
Posted by: Guest on May-12-2021

Code answers related to "how to return array in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language