I have created a class as follows.
package basics;
public class Basics {
public int intMaths;
public int intEnglish;
public int intScience;
}
Then I have created another class as the following and both classes are in the same package.
package basics;
public class AccessVaria {
}
Now I want to access the variable in the Basics.java class from the AccessVaria.java class.
I have tried to do that like this
intMaths = 80;
But I cannot do that and give me a suggestion. Do java always request for getter() & setter() methods to access variables from different classes even if the variables have the public access modifier ?
I have access public variables in one class from another class in C#.Net but they didn't give suchlike bad experience.
So if someone can explain how to solve this matter ?
Thank You!
Chiranthaka