I have been taught this too and I do prefer interfaces where possible (of course I still use inheritance where is make sense).
One thing I think it does is decouple your code from specific implementations. Say I have a class called ConsoleWriter and that gets passed into a method to write something out and it writes it to the console. Now lets say I want to switch to printing out to a GUI window. Well now I have to either modify the method or write a new one that take GUIWriter as a parameter. If I started by defining a IWriter interface and had the method take in an IWriter I could start with the ConsoleWriter (which would implement the IWriter interface) and then later write a new class called GUIWriter (which also implements the IWriter interface) and then I would just have to switch out the class being passed.
Another thing (which is true for C#, not sure about Java) is that you can only extend 1 class but implement many interfaces. Lets say I had a classes named Teacher, MathTeacher, and HistoryTeacher. Now MathTeacher and HistoryTeacher extend from Teacher but what if we want a class that represent someone who is both a MathTeacher and HistoryTeacher. It can get pretty messy when try to inherit from multiple classes when you can only do it one at a time (there are way but they are not exactly optimal). With interfaces you can have 2 interfaces called IMathTeacher and IHistoryTeacher and then have one class that extend from Teacher and implement those 2 interfaces.
One downside that with using interfaces is that sometimes I see people duplicate code (since you have to create the implementation for each class the implement the interface) however there a clean solution to this problem, for example the use of things like delegates (not sure what the Java equivalent to that is).
The think the biggest reason to use interfaces over inheritances is the decoupling of implementation code but don't think that inheritance is evil as it is still very useful.