Example

public class ClassA {
Object o;
String s;
public void methodA() {

s = (String) o;
// ...
}

}
Solution Ensure that the object o is a String
Example

public class ClassA {
String s;
Object o;
public void methodA() {

if (o instanceof String){
s = (String) o;
// ...

}

}