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 |
Are arrays passed by reference in java?
What is a singleton class in Java? And How to implement a singleton class?
what type of questions asked for barclays technologies pune please send urgent
How can an object be unreferenced?
What is bubble sorting in java?
What is a class variable?
What is Runtime class and its purpose?
Which list does not allow duplicates in java?
What does split function do in java?
Which command from the jdk compiles a java program?
What is the difference between menuitem and checkboxmenu item?
What is the purpose of having the concept of overloading?