Simply put here is what I am trying to do:
class Main {
public static void main (String[] args) {
List option = new List();
SetGet call = new SetGet();
option.names();
call.getName();
}
}
class List {
public void names() {
SetGet tell = new SetGet();
tell.setName("Frank");
}
}
class SetGet() {
private String info;
String getName() {
return info;
}
public void setName(String name) {
info = name;
}
}
Essentially I have a main method that will tell another method from another class to set the name of something. Yet whenever I request getName from the main method, it always comes back null even though I already set a name for it. This is a really simplified version of what I am trying to do. Any assistance is greatly appreciated.
SetGet(usingnew SetGet()). And thenames()method creates an instance, sets the name, but then discards the newly created instance, because you don't return it or store it in a field.