aspose file tools*
The moose likes Beginning Java and the fly likes polymorphism Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "polymorphism" Watch "polymorphism" New topic
Author

polymorphism

sandeep Talari
Ranch Hand

Joined: Dec 24, 2007
Posts: 63
chapeter 2 ..94th page
in kathy book scjp..

how does this following code works any body please explain

public class Horse extends Animal
{
private Halter myHalter;
public void tie(LeadRope rope)
{
myHalter.tie(rope);
}
}
public class Halter(
public void tie (LeadRope aRope)
{}

}
Bill Shirley
Ranch Hand

Joined: Nov 08, 2007
Posts: 457
use the code tags,

looks like you're missing a LeadRope class,

have you run it through a compiler?

what was the error?


Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);
sandeep Talari
Ranch Hand

Joined: Dec 24, 2007
Posts: 63
thanks paul
sorry this is the exact code given in the kathy sierra book of scjp
i didn't get it nothing is there

i remember the exception its nullpointer exception
Mark Newton
Ranch Hand

Joined: Jan 31, 2006
Posts: 129
Sandeep, I think you need to read HowToAskQuestionsOnJavaRanch.

To get meaningful advice, you really need to post a lot more information than you've given us, for example, you're obviously running this code somehow, but I don't see a main method anywhere. I haven't tried, but I'm pretty sure that the code you've given us won't compile, so something is definitely missing between what you're seeing and what you're telling us that you're seeing.

Also, just saying that you remember it was a NullPointerException isn't really enough - you should have a stack trace that tells you exactly where the exception was thrown, among other things - all of that is useful information.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11313
    
  16

also, be sure you read the book carefully. There are many examples in the book that are not meant to be complete, executable code samples, but just enough code to illustrate a point. It is not all meant to be typed up, compiled and run.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: polymorphism