About problem
Eventually when i try cast Object to ArrayList i've problem when i use method from ArrayList like .size(), .get():
That the error returned to me:
error: cannot find symbol
Source
public String parseValueParam(Object value) throws InvalidAttribute{
if(value instanceof ArrayList){
value = (ArrayList) value;
String result = "";
for(int i = 0, _len = value.size(); i < _len; i ++){
result += this.parseValueParam(value.get(i));
if (i < _len - 1) result += " , ";
};
return result;
} else if(helper.isString(value)){
return value.toString().replaceAll("'", "");
} else if (helper.isInteger(value) || helper.isDouble(value)){
return value.toString();
} else {
throw new InvalidAttribute("Invalid attribute type");
}
}
I've tried to declare couple of methods with same name one using Object to accept String, Int and Double and another only accept ArrayList. However when i run my code execute only the use Object.
public String parseValueParam(ArrayList value) throws InvalidAttribute{
String result = "";
for(int i = 0, _len = value.size(); i < _len; i ++){
result += this.parseValueParam(value.get(i));
if (i < _len - 1) result += " , ";
};
return result;
}
Listif you know you're going to be dealing with lists anyway?List<?>? Besides, you don't care what's in the list, you only care that it is aList.