variables - Why only one result(no multiple values) of methods in Java? -


in languages possible return more 1 result function. example in python:

def func(x): return x, x**2, x**3 ... a, b, c = func(2)

why java has 1 result?

my assumption is: because of atomic operations. means java trying avoid inconsistent state (like , b set, c not yet).

is true? other thoughts?

return returning control caller. while returning stack variables,register , other variables associated removed stackframes variables declared inside function earlier vanished memory. if multiple values needed returned returned data structures arrays,list, maps etc.


Comments

Popular posts from this blog

command line - Use qwinsta in PowerShell ISE -

java - Incorrect order of records in M-M relationship in hibernate -

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -