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
Can java run on google chrome?
What is the difference between conversation & casting?
What is treeset in java?
Explain about interthread communication and how it takes place in java?
Why is method overloading not possible by changing the return type in java?
What is the difference between comparison done by equals method and == operator?
What are the advantages of unicode?
Can you override static methods?
Which package has light weight components in java programming?
How do you use find and replace?
What is the destroy method?
What is Session reduplication and how its done?
What are thread local variables?
What is the difference between serializable and externalizable interface?
What is udp in java?