I have a Value Class and there is an Object value in it. I want to use the value as String, Integer or Double.
The asDouble method controls instanceof value object. If it is not Double or Integer returns 0.
Generally it works but sometimes although it is Double returns 0;. I couldn't the reason of it.
When I debug I can see:
Here is my Value class
public class Value{
public Object value;
public Value(Object value) {
this.value = value;
}
public Double asDouble() {
if (this.value instanceof Integer || this.value instanceof Double) {
return Double.parseDouble(String.valueOf(this.value));
} else {
return 0.0;
}
}
}
Could anybody explain where did I go wrong
