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 |
What is the finalize method do?
Is Constructor possible in abstract class in java ?
What is command line used for?
Which one of the following suits the description of a string better: derived or primitive?
Can we create an object of static class in java?
how to use this key word in java programming?
What are possible key words, we can use to declare a class?
Is it possible to use string in the switch case?
What is meant by singleton class?
Explain access modifiers in java.
What is string in java is it a data type?
Can a class with private constructor be extended?