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 does ide stand for?
Variable of the boolean type is automatically initialized as?
How can a gui component handle its own events?
What loop means?
How is Object Oriented Programming different from Procedure Oriented Programming?
What does it mean to be immutable?
Can we execute a program without main() method?
What is deserialization?
What is adapter in java?
What are the 8 primitive data types in java?
Explain java coding standards for methods?
What is linked hashset and its features?
How many static init can you have?
What are inner classes or non static nested classes in java?
Can you override private or static method in java?