Java support call by reference (pass by reference) ?
Answer Posted / sarju001
yes java support call by reference only using StringBuffer
class.
Here, is an example of call by reference
public class PassByReference
{
public static void passref(StringBuffer s)
{
s = s.insert(8, "j2ee & ");
System.out.println(s);
}
public static void main(String[] args)
{
StringBuffer str = new StringBuffer("Welcome java
program");
System.out.println(str);
passref(str);
System.out.println(str);
}
}
output :-
Welcome java program
Welcome j2ee & java program
Welcome j2ee & java program
| Is This Answer Correct ? | 9 Yes | 0 No |
Post New Answer View All Answers
What is the use of protected in java?
What is java full form?
Difference between error and exception
Why parameters should be passed by reference?
Explain the difference between jdk, jre, and jvm?
When will we prefer to use set and list in java and why?
What does the append?
What is charat java?
What is the function of java?
What is the purpose of main function in java?
Which collection does not allow duplicates in java?
what is thread? : Java thread
What is bifunction in java?
Explain public static void main(string args[]).
What is this () in java?