Are you casting to int or Integer?you cannot cast to an int, as it is a primitive andnot a subclass of Object.If you want to save the value as an int, use thefollowing:((Integer)(s.getValue())).intValue();