Hi, If I have an interface A. And another interface that extend it called Aa. I have a class that implement Aa (donc implement A too). My third interface (please follow me I am almost done ) called B, have a method that will return an Object that implements Aa. My question: I read somewhere that when declaring variable it is better to declare them using their interface if they have one...What should myMethod() return? 1- A myMethod()? 2- Aa myMethod()? /Daniela
Your program may well have the greatest potential utility if it uses more generic data types. By more generic data types I mean data types further up on the inheritance heirarchy. So, if it makes sense for your application, returning an object of type A would potentially provide for the greatest future flexibility.
ok, I understand... thank you do you have the answer to my second thread? I want to know the javac arguments to compile all the java files in subdirectories... the only way I know is when I go as deep in my directory structure and type : javac -d c:\project *.java Is there a way to compile all the java files in all the subdirectories? thanks again /Daniela
It depends on what you need. Let's fill in some blanks. interface A has method1 interface Aa has method2 When I run my method in B and return an object, what am I going to do with that object? Am I going to run method1 only? Then returning an object of type A might make sense. if I am going to run method2 then I need to have an object of type Aa returned.
Interface A and interface Aa have the same methods. The only difference between the two is that Aa extends Remote. But everything will work fine if I return an interface A. So I will keep it like this... thank you /Daniela
you can check it in the java tutorial in SUN --- Robbies ----------------------------- 1.java IDE tool : JawaBeginer 2.Java Jar tool : JavaJar http://www.pivotonic.com