class Sample {
int num;
void method() {
num = 1; // Sample.num is set to 1
int num = num = 2; // num in method is set to 2, the second num is num in method
num = 3; // num in method is set to 3
}
}
I tried the code in https://www.tutorialspoint.com/compile_cpp_online.php
class Sample {
public:
int num;
int method() {
num = 1;
int num = num = 2;
num = 3;
return num;
}
};
Sample s;
cout << s.num << endl;
cout << s.method() << endl;
cout << s.num << endl;
Output:
0
3
1
but your tag is Java, so it should be interpreted as Java code. I will try it in Java.