In Java, to access any properties of a given class, you have to create the object first.
Therefore if you want to access the properties of class
Basics
inside class
AccessVaria
, then you have to create a instance of class
Basics
inside
AccessVaria
.
For more information
click here.
"..Do java always request for getter() & setter() methods to access variables.."
Java suggest you not to access the properties directly, use getter/setter method to access the properties. It is a coding convention.