How to create a function that returns more than one parameter | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How to create a function that returns more than one parameter

16th Jun 2019, 9:54 PM
jurise mboumene
jurise mboumene - avatar
6 Answers
+ 7
Perhaps return an object with several fields?
16th Jun 2019, 10:33 PM
Sonic
Sonic - avatar
+ 4
Mustafa Coder, this is taged Java
16th Jun 2019, 11:18 PM
zemiak
+ 3
Sonic You can that by call refference, that's means you make changing directly on variable's value by address. Ex: int x=3, y=4; swap(x,y); void swap (int &x,int &y) { int z; z=x; x=y; y=z; } Then you will not need to return any value, in same way to object variable.
16th Jun 2019, 11:06 PM
Mustafa Coder
Mustafa Coder - avatar
+ 2
Or Hashtable. Which is closest to dictionary or associative array.
16th Jun 2019, 10:45 PM
Toni Isotalo
Toni Isotalo - avatar
+ 2
zemiak Oh! sorry, I didnt note that, I thougt it in C or C++, I havnt any knowledge about java.
16th Jun 2019, 11:51 PM
Mustafa Coder
Mustafa Coder - avatar
+ 1
Add the name inside parenthesis. If multiple perameters then seperate with a comma.
17th Jun 2019, 10:07 AM
Erick Gonzalez
Erick Gonzalez - avatar