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;
}
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;
}
How to return a String array in Java
import java.util.*;
public class Main
{
public static String[] return_Array() {
//define string array
String[] ret_Array = {"Java", "C++", "Python", "Ruby", "C"};
//return string array
return ret_Array;
}
public static void main(String args[]) {
//call method return_array that returns array
String[] str_Array = return_Array();
System.out.println("Array returned from method:" + Arrays.toString(str_Array));
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us