cast an Object to another class
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   ken_carey
Posted On:   Thursday, February 20, 2003 06:22 AM

Hello, i am calling a remote procedure , Print, which has several parameters : Print(int fileType, Object data) Are the parameters passed by value or reference. I wish to cast the Object data to a class called PrintableFile inside the method Print. I am getting a ClassCastException when I attempt to do this : PrintableFile myPrinter = new PrintableFile(); myPrinter = (PrintableFile)data; // this causes the error. The remote method is called as follows : Print(2,new PrintableFile()) . The class PrintableFile() is a simple class that implements Serializable and has a byteArray property (the file to print).    More>>

Hello,



i am calling a remote procedure , Print, which has several parameters :


Print(int fileType, Object data)


Are the parameters passed by value or reference. I wish to cast the Object data to a class called PrintableFile inside the method Print. I am getting a ClassCastException when I attempt to do this :


PrintableFile myPrinter = new PrintableFile();

myPrinter = (PrintableFile)data; // this causes the error.



The remote method is called as follows :


Print(2,new PrintableFile()) .


The class PrintableFile() is a simple class that implements Serializable and has a byteArray property (the file to print).


Any ideas as to why i'm getting the error ?


Thanks,




Ken

   <<Less
About | Sitemap | Contact