0
How to use a variable from one method to another
for example if a have a var x in method 1 and how can i use that variable to another method 2?
2 Answers
0
public void method2(int var) {
var += 4;
}
public void method1() {
int x = 4;
method2(x);
}
0
If any variable is created inside a function, it will be destroyed when the function ends, so there is no way to do that.