class Test {
	// Instance variable or member variable
	private int value = 10;

	void method() {
		// This local variable hides instance variable
		int value = 40;

		System.out.println("Value of Instance variable :" + this.value);
		System.out.println("Value of Local variable :" + value);
	}
}

class UseTest {
	public static void main(String args[]) {
		Test obj1 = new Test();
		obj1.method();
	}
}

Value of Instance variable :10
Value of Local variable :40

相关文章:

  • 2022-12-23
  • 2021-09-13
  • 2021-11-01
  • 2022-12-23
  • 2022-12-23
  • 2021-07-29
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-18
  • 2021-06-18
  • 2022-12-23
  • 2022-01-08
  • 2021-07-02
相关资源
相似解决方案