-1

I am new to java. Can anyone please tell me best way to access private method variables in another class. Thank u

Rehan Shikkalgar
  • 1,029
  • 8
  • 16

1 Answers1

2

Private variables are private for a reason- you're not supposed to be able to access them directly. Many classes do have getter methods though which allow you to access private variables but not change them. If you need to access private variables in your program, you need to rethink your design.

connorp
  • 254
  • 2
  • 12