Results 1 to 2 of 2
Thread: 'Casting' couch !!
- 12-20-2007, 09:39 AM #1Member
- Join Date
- Dec 2007
- Rep Power
'Casting' couch !!
Well, what I need to do this.
I have designed an interface; and two classes c1 and c2 that implement this interface. Now, I need to create an object of one of the classes (dynamically), but assign it as an interface instantiation. That is,
class c1 implements i
class c2 implements i
Now, I know the following will work ::
i i_obj = new c1();
i i_obj = new c2(); // Fine till here !!!!!!!!!!!!!!!!!!!
But suppose I now want to the same thing, but the 'class type' must be known at run time, through the 'Properties class' object, by making use of Class.forname() function.
NOW, how do i proceed ??
Looking forward to reply.
- 12-22-2007, 01:05 PM #2
- By kurtulas in forum New To JavaReplies: 2Last Post: 02-16-2008, 08:03 PM
- By rhm54 in forum New To JavaReplies: 2Last Post: 02-07-2008, 12:06 PM
- By ajaygargnsit in forum Advanced JavaReplies: 4Last Post: 01-04-2008, 04:54 PM
- By leebee in forum New To JavaReplies: 5Last Post: 08-10-2007, 12:24 PM