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
How do singleton patterns work?
Why is singleton instance static?
What is communist flag?
If try block is successfully executed, Then Is Finally block executed?
Implement 2 stacks with just 1 array. The stack routines must not indicate overflow unless every slot in array is used.
What is an example of a conditional statement?
Why there is no call by reference in java?
What is string and its types?
What is arrays sort in java?
Is arraylist ordered in java?
When a lot of changes are required in data, which one should be a preference to be used? String or stringbuffer?
Difference between this() and super() in java ?
Can I use % with real numbers?
What is the biggest integer?
Can there be an abstract method without an abstract class?