Computer Science, asked by vickysmilevick5087, 10 months ago

With the help of an example show how can you return more than one value from a function.

Answers

Answered by velvissilva2005
0

Answer:

If you use if statement or condition based statements then you can have more than 2 return types.

OR you could return an array

import java.util.*;  

 

class GfG {  

   public static List<Object> getDetails()  

   {  

       String name = "Geek";  

       int age = 35;  

       char gender = 'M';  

 

       return Arrays.asList(name, age, gender);  

   }  

 

   // Driver code  

   public static void main(String[] args)  

   {  

       List<Object> person = getDetails();  

       System.out.println(person);  

   }  

}

Answered by smritiyadav81
0

Answer:

it is a answer of this question

Attachments:
Similar questions