Since Java doesnt support pointers, How is it possible to call a function by reference in Java like we do in C and C++??
Yes, you can implement Call by Reference in another way by "Pass by Reference".
In below code the original data --> x is manipulated by passing the reference object.
public class Method_Call {
static int x=50;
public void change(Method_Call obj) {
obj.x = 100;
}
public static void main(String[] args) {
Method_Call obj = new Method_Call();
System.out.println(x);
obj.change(obj);
System.out.println(x);
}
}
Output: 50 100