0

Guys help me please

In java how can i return two values using an array

27th Jul 2020, 5:35 AM
ocan junior
ocan junior - avatar
5 Antworten
+ 6
ocan junior You can put only same data type of values in an array. If the values are of same data type then you can store in Array and return that array.
27th Jul 2020, 5:41 AM
A͢J
A͢J - avatar
+ 3
Hi ocan junior Could you please change your post title to reflect the question? This will maximize your chances of receiving useful answers, and facilitate search by others. https://www.sololearn.com/Blog/38/8-simple-rules-to-get-help-from-the-community Thanks.
27th Jul 2020, 5:45 AM
ifl
ifl - avatar
+ 2
Though there are only few cases of relevance, it's basically possible to put objects of different data types into an array, if this is defined of more generic type (and finally Object can contain everything). https://code.sololearn.com/crU9NbY0dnGx/?ref=app But you should normally not use this. Valid use cases are not e.g. misusing this to be able to return multiple values from a method. Valid would be a list of "Product", where I put inherited "Fruit" or "Package" objects, which are derived from Product. But there's quite sure a cleaner solution for your case...
27th Jul 2020, 9:41 PM
Sandra Meyer
Sandra Meyer - avatar
+ 1
return an array
27th Jul 2020, 6:41 AM
Oma Falk
Oma Falk - avatar
0
Mention some about that values too, ie: situation. Actually, you don't need to return array if you pass array to that function, modification in function reflect same in original passed array...
27th Jul 2020, 7:30 AM
Jayakrishna 🇮🇳