cancel
Showing results for 
Search instead for 
Did you mean: 

New Object instance

Former Member
0 Kudos

I have a method call dumpEnvelope,

if everytime i call the dumpPart , i will call the dumpEnvelope,....

if i call dumpEnvelope , i want to create a new object of inMailBean

how do i do that....

previously, what i do is like this...

InMailBean inMailBean=new InMailBean();

only create 1 instance of object...

i want everytime i call dumpEnvelope((Message)p,out,New OBJECT ->inMailBean(),invalidMailAck)

dumpPart(){

dumpEnvelope((Message)p, out, inMailBean,invalidMailAck);

}

dumpEnvelope(Message m, PrintWriter out, InMailBean inMailBean,InvalidMailAck invalidMailAck){

}

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

If I understood correctly, you want to create new object of InMailBean every time u call dumpEnvelope. If this is correct, then u can do it as follows:

dumpEnvelope((Message)p,out,new InMailBean(), invalidMailAck)

Thanks.

Best Regards,

Shiva

Former Member
0 Kudos

InMailBean inMailBean;

inMailBean=dumpEnvelope((Message)p, out, new InMailBean(),invalidMailAck);

java.lang.ClassCastException

abhijeet_mukkawar
Active Contributor
0 Kudos

hi,

does dumpEnvelope has return type InMailBean ?

regards

Former Member
0 Kudos

i solve my problem..

abhijeet_mukkawar
Active Contributor
0 Kudos

hi,

so create new instance of InMailBean in dumpEnvelop() and return if from that,

cerate new instance with

InMailBean newObj = new InMailBean(); ///just like how you did earlier

return newObj;

so return type of dumpEnvelop() , dumpPart() will be InMailBean, since dumpEnvelop() return this type object to dumpPart() and which in turn return that new obj to calling place. e.g,

InMailBean dumpPart(){}

same for dumpEnvelop()

is that what you were looking for

let me know if it was smthing else

regards