A class that contains the variables and their values, and I need some simple way to feed the other class with those variables.
For example, I have a class with the String urlPage = 'www.abc.com'
variable. This urlPage
can change the times, but I did not want to change in all classes that use this value, I wanted to change only in the class where it is defined. So, in the other classes, in their due methods, I would only inform the variable, and they would already understand that its value is 'www.abc.com'.
I made this work with get
and set
, but I wanted to know if there is a simpler way, since it would not be just one variable, it would be several, and I think it would work to make a get
e set
for each one.
I've done the following:
public class UsedLinks {
private String homepagelink = "abc.com.br";
public void setHomepage( String homepage)
{ this.homepagelink= homepage; }
public String getHomepage()
{ return this.homepagelink; } }
Already in the other class, I just called
Usedlinks link = new Usedlinks();
link.gethomepage();
But I found a lot of work being that I will not only use the URL as a variable.