'Java calling enum internally return null [closed]
I am trying to set an enum value to an object, the enum value is coming from calling the method in the same class, but it always return null value. In this case, trying to set the value of "setInfo" always come back as null. Why "this.getSource()" return null? Shouldn't it return SourceEnum.X?
public class B implements C
{
public void process()
{
A a = createA();
...
...
}
private A createA()
{
A a = new A();
a.setInfo(this.getSource());
return a;
}
@Override
public SourceEnum getSource()
{
return SourceEnum.X;
}
}
public enum SourceEnum
{
X,Y,Z
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
