Access modifiers in Java

  • Main and Practice are in the same package.
  • We can use public, protected, and default methods in Practice class, but we have compiler error for our private method. Because it is accessible within the same class only.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store