aspose file tools
The moose likes Beginning Java and the fly likes Polymorphic Arguments Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Polymorphic Arguments" Watch "Polymorphic Arguments" New topic
Author

Polymorphic Arguments

Niyas Ahmed Sheikh
Ranch Hand

Joined: Jun 15, 2005
Posts: 129
Hi,

I have tried the below sample coding to know how the polymorphic arguments are working.



By the above coding, I'm not getting any error.

But the below codings, raise the error. Just I have included the System.out.println statement to know the flow of thr pgm.



Any other advise/desc/hidden facts about the polymorphic arguments are WELCOME!
Niyas Ahmed Sheikh
Ranch Hand

Joined: Jun 15, 2005
Posts: 129
Sorry..forget to give the error message

And here we go!!!




















































Mani Ram
Ranch Hand

Joined: Mar 11, 2002
Posts: 1140
Originally posted by Niyas Ahmed Sheikh:
Just I have included the System.out.println statement to know the flow of thr pgm.


You can't have statements like that. The statements should be present inside a method, or a constructor or a static block...

For example, you should change your Manager class as


Mani
Quaerendo Invenietis
Steve Simon Joseph Fernandez
Ranch Hand

Joined: Jul 17, 2005
Posts: 35
Hi,

Executable statements (in this case, System.out.println()) have to be placed inside a method. Put your println's inside the class constructor.

_steve.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Polymorphic Arguments
 
Similar Threads
whats wrong with my code ?
Polymorphism, arguments and instanceof questions
Method in parent class....
specific method
can you explain me classCastException ?