java amateur
You can not instantiate an instance of an abstract class, you must subclass it and then implement it's abstract methods in your sub class.
java amateur
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
BTW: Translate Contrato for me. It has a very nice ring to it. I hope it's not something mundane, but this being a programming problem I don't have high hopes.
All that compiles and runs when other classes call with an instance of ContratoParticular or ContratoConvencao. The Person class never knows or cares which one it is. Person can even call methods defined on Contrato without ever knowing what concrete class it has. The beauty and power of abstraction at work!
java amateur
JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
java amateur
Originally posted by miguel lisboa:
i've playing with all this for a while and i noticed that, when i query, i've to mention the right subclass. Is this allways like this?
(i'm using hibernate)
JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
For your specific case, check out this very similar thread.Originally posted by miguel lisboa:
by any chance do you know how to map inheritance with hibernate?
I'm not sure what you mean by "I've to mention the right subclass". Which line of code in your example illustrates the idea you are trying to convey here?
It comes in handy when you have two different types of Pessoas that have the same method that returns different things.
For example, you may have two types of Animais, Gato and Cavalo. Gato and Cavalo extend Animal. Gato and Cavalo each have a method called fala() but they return different things. Try putting a Gato and a Cavalo into a List and then call
System.out.println( animal.fala());
java amateur