Java support call by reference (pass by reference) ?
Answer / 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 |
Which is bigger float or double?
Difference between stack and queue?
Why constructor has no return type?
Can you sort a string in java?
Explain about the dynamic behavior of core java?
Which language is java?
What is class and object in java?
What is keyword and identifier?
What is the difference between Byte stream and Charecter Stream?
What are synchronized blocks in java?
Difference between Encapsulation and Abstraction
What are conditionals and its types?