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 |
how come we know the object is no more used in the class?
Is a method a function?
What is singleton class in ruby?
Explain your academic project?
2 Answers Accenture, Levonsys, SDF, TCS, Tech Mahindra,
is JVM platform dependent or independent..?
11 Answers IBM, Tech Mahindra,
Which java version is latest?
How many types of syncronization?
Explain cookies?
extending thread class or implementing runnable interface. Which is better? : Java thread
What is numeric data type?
what is the difference between a java object reference and c++ pointer?
What is garbage collection? Can it be forced to run?