This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
well Thanks for your reply and Here class is only abstract and methods are not but defined methods in abstract class are returning something and I want to use that
Suhas Bilaye
Ranch Hand
Joined: Sep 10, 2009
Posts: 80
posted
0
You simply need to create a subclass which extends from the abstract class. Then using the instance of this subclass you can use the defined methods of the abstract class.
Thanks and Regards,
Suhas
http://www.xplore-java.blogspot.com/
Suhas is right. You can call abstract methods of an abstract class without problems. This is because you can only instantiate concrete classes, and concrete sub classes of abstract classes have implemented the abstract methods.
thats quiet hepfull, and bit confused also and actually I have a file names Hello.java which is a abstract class and I have a one method init and I have onemore class called use.java and both are in same packeage and I want to use method in Hello.java which is a abstract class in Use.java How can I do that?
Christian Dillinger
Ranch Hand
Joined: Jul 20, 2009
Posts: 172
posted
0
Did you understand Rob's sample? If not, read it again. If you did, your problem should be solved. But to help us to help you, you should post your code here...
There is a method type() in RescueObject you have to implement in order to get a concrete class - as long as you don't you'll never ever get a class that not abstract.
Yes; you have no reference to the classes you've already compiled.
Note that most here will encourage you *not* to set the classpath environment variable, as it can cause a lot of confusion. It's often easier to supply the classpath directly to the Java compiler.
sorry for late reply I have been quite busy with some other work ,as you said about supplying classpath to the java compiler, here there is a makefile to compile all java programs at once and I am confused how to supply the classpath at compilation time
I compiled the program successfulyy but I was unable to use the values returned by the method which is in abstract class. I dont no whats wrong with this code ..
MovingObject.java
So I created one class which extends MovingObject.java and named as myMovingObject.java
But Its not calling any methods in superclass!!!
myMovingObject.java
3) your only assignment to m_routePlan occurs on line 21: "m_routePlan = mv.routePlan();". mv's own copy of m_routePlan has never been assigned though, so it still returns null. mv gets created on line 20. Its constructor does not set its m_routePlan field so it stays null. You then ask for it on line 21, and since it's null your object's m_routePlan field is set to null as well.
thanks for your reply and what am I suppose to do to overcome this problem?
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32651
4
posted
0
You will have to find out about the constant interface anti-pattern and alter your interfaces accordingly.
You will have to alter the constructor to make sure the route plan is instantiated.
The latter being the most important advice. The anti-pattern doesn't prevent your program from working, it's just bad style. And yes, Sun has used this bad style as well (in Swing among others. SwingConstants, sight...).
You mean I need to crate one constructor then I need to instantiate the routeplan in this constructor right
Rahul Kurup
Greenhorn
Joined: Dec 11, 2009
Posts: 9
posted
0
When you create a new object as
MovingObject mo = new Use();
constructor for Use() will be called which will in turn invoke the parent class constructor(MovingObject). Now MovingObject does not have a zero argument constructor. Also
Use does not have a constructor that calls super().
Could this be the problem? Experts please confirm.
I have been working on this past two weeks but no progress and I really appriciate if somebody could sort the problem..experts I really Need your valuable suggestions thanks in advance
I would *strongly* suggest starting a new thread, posting your complete code, and asking some very specific questions--this thread has gotten very difficult to follow, and I'm not even sure what problem you're having at this point.
Normally I wouldn't, but I'm going to lock this thread to make you start over. Before posting the new thread, I'd make sure your code is as clean as possible, formatted nicely, and so on. It'll also give you an opportunity to look over your existing code and figure out exactly what's wrong and what you need to ask. You may be able to answer your own question, too--sometimes taking a step back is very helpful.