Making Data available to every class in a project.
I am new to java.
I have a java class (GetData) that imports and processes data from a database. This data is used by other classes in my program. The GetData class is invoked by the main class of my program.
In order to make these data available to every single class I am using the following approach: Every time an instance of a class is created, an instance of the GetData class is passed to the invoked class through the constructor.
Is this the right approach to accomplish this? Are there any other solutions?
I come from procedural programming where external variables can be used to accomplish this.Java does not have such a thing.