File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes creating objecct Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "creating objecct" Watch "creating objecct" New topic
Author

creating objecct

Saumyaraj Zala
Ranch Hand

Joined: Aug 06, 2012
Posts: 56

PLEASE PROVIDE REASON ABOUT THE ERROR



Why do we fall? So that we can learn to pick ourselves up.
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
What is the error? And please KeepItDown
changu mani
Ranch Hand

Joined: Aug 31, 2012
Posts: 30
During compile time, compiler is not aware of what kind of object ob is pointing to. So it is necessary to do external casting.
Do this way, the compiler error goes away.

Sub ob1= (Sub)ob;
Abc ob2=(Abc)ob;
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

changu mani wrote:During compile time, compiler is not aware of what kind of object ob is pointing to. So it is necessary to do external casting.
Do this way, the compiler error goes away.

Sub ob1= (Sub)ob;
Abc ob2=(Abc)ob;


The first line is legal. The second will give ClassCastException at runtime.
Niranjan Aithal
Greenhorn

Joined: Mar 17, 2012
Posts: 6
changu mani wrote:During compile time, compiler is not aware of what kind of object ob is pointing to. So it is necessary to do external casting.
Do this way, the compiler error goes away.

Sub ob1= (Sub)ob;
Abc ob2=(Abc)ob;


Looks like you read: public class Sub extends Abc
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: creating objecct