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 argument in java?
What are filterstreams?
Does hashset allow duplicates in java?
How is java created?
What is the use of predicate in java 8?
What is entry set in java?
What does java stand for?
What is data string?
In a container there are 5 components. I want to display the all the components names, how will you do that one?
How do you execute a thread in java?
What does next mean in java?
What technique can be employed to compare two strings?
Why main method is static in java?
What is the synonym of string?
What is return in java?