Click here to Skip to main content
15,902,810 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
in c# has out parameter in void
as

void x(out string z)
{
z="dd";

}

ok
how i can in java

thanks for any help
Posted

this[^] might help you.
 
Share this answer
 
Comments
Mostafa Elsadany 11-Mar-11 0:03am    
thanks for help
but no way in this page to out in java
so it's mining no out parameter in java
Sergey Alexandrovich Kryukov 11-Mar-11 0:09am    
Yes, of course! Did you see my Answer: no out or ref in Java, only by value? There is a work-around.
--SA
[no name] 11-Mar-11 0:56am    
Yes. there is no out parameter in Java.
Java does not support out parameter; all parameters are passed by value, but a parameter can be of mutable reference type, in this case, even though the instance of a parameter can not be modified referentially, the object itself can be modified inside the function and returned modified.

See this: http://www.javacamp.org/javavscsharp/outparam.html[^]. A primitive or immutable type can be modified as a result of call by wrapping it in a class or passing it as a reference of array (which is a reference type and mutable.

See also about mutable and immutable objects: http://www.javaranch.com/journal/2003/04/immutable.htm[^].

—SA
 
Share this answer
 
Comments
Mostafa Elsadany 11-Mar-11 0:21am    
thanks for help
Sergey Alexandrovich Kryukov 11-Mar-11 0:26am    
You're welcome,
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900