In the classes I am coding, I tend to have to cast variables to other datatypes quite commonly. I wanted to make a method that could truncate this process. I wanted it to be something like this:
public static Object typeCast(Object o, DataType type){
if (o instanceof type){
return (type) o;
}else{
return false;
}
}
However, I know of no way to save a data type as a variable. Is this possible?
Classobjects.