Java call by value?

Asked 2 years ago, Updated 2 years ago, 19 views

As far as I know, when passing objects in Java,

This is a call-by-reference.

When passing a general variable (int, etc.),

I know it's Call by Value, is that right?

Is there a way to turn the general variable over to the reference?

Thank you

java

2022-09-22 11:34

1 Answers

You must use the wrapper class.

It is wrapped in classes such as Integer and Long and delivered.

int i = 10;

Integer intObj = new Integer(i);


2022-09-22 11:34

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.