Question: I saw a class "AttributeSelectedClassifier" was once created in the following ways:

```
AttributeSelectedClassifier classifier = new AttributeSelectedClassifier();

classifier.setClassifier(base);
classifier.setEvaluator(eval);

```

This above one looks natural to me. But how about the following one.

```
classifier = new AttributeSelectedClassifier();
((AttributeSelectedClassifier)classifier).setClassifier(base);
((AttributeSelectedClassifier)classifier).setEvaluator(eval);

```

I think it should be right, but I am not quite sure about the way of of defining classifier as ((AttributeSelectedClassifier)classifier), how to understand this usage?

Answer: 
This means that the classifier variable is declared as a superclass or superinterface of `AttributeSelectedClassifier`, and that you need to call a method which is not defined in the class or interface, but only on `AttributeSelectedClassifier`. This notation *casts* the variable to `AttributeSelectedClassifier`:

```
Object classifier = new AttributeSelectedClassifier();
// classifier is a AttributeSelectedClassifier, but references as Object
// to call the following method, we need to cast it to AttributeSelectedClassifier
((AttributeSelectedClassifier)classifier).setClassifier(base);
((AttributeSelectedClassifier)classifier).setEvaluator(eval);

```

This is usually the sign of a design problem. Either the methods should be in the superclass or interface, or the variable should be declared as `AttributeSelectedClassifier`.
By doing `((AttributeSelectedClassifier)classifier)` you are casting ("*forcing*") the `classifier` object to behave like an instance of `AttributeSelectedClassifier`.

The `classifier` variable was probably previously declared as a superclass of AttributeSelectedClassifier.