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 |
can abstract class have constructor how can you achive this ?
What is CardLayout?
Is it safe to install java on my computer?
Is it compulsory for a try block to be followed by a catch block in java for exception handling?
why we import both packages java.awt.*; and java.awt.event.*; as java.awt.*; can import all classes na. then what is the need of importing java.awt.event.*; ?
What is java lang object?
Why string is not a wrapper class?
What is array length?
Can inner class final?
What is function and method in java?
What is an infinite loop?
What is the length of a string?