Answers for "java return string array from method"

0

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));
 
    }
}
Posted by: Guest on August-23-2021

Code answers related to "java return string array from method"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language