I recently read that I should use general classes instead of specific classes when proramming.
I can't figure out why it is suggested.

example: Let's say that we have a class MyPanel that inherits from JPanel. MyPanel a non-inherited method called getLastChild.

instead of:

```
MyPanel panel = new MyPanel():
Component last = panel.getLastChild();

```

it is suggested to do this:

```
JPanel panel = new MyPanel();
Component last = ((MyPanel)panel).getLastChild();

```

I don't see why I should choose the second one.