SABYASACHI S GUPTA wrote:
>
> Yup I figured that out ...
> but how do I do a typecast when I have the class name in a String
> variable during runtime. (I do NOT know the class name to typecast).
Ah, I guess I really did understand your original question and gave
decent advice :-). If you're try
SABYASACHI S GUPTA wrote:
> Yup I figured that out ...
> but how do I do a typecast when I have the class name in a String
> variable during runtime. (I do NOT know the class name to typecast).
You don't really have to typecast. Just call your intended method via reflection:
ie: use Class.forNa
nt: Friday, November 05, 1999 9:22 AM
> To: [EMAIL PROTECTED]
> Subject: Re. about Class class
>
>
>
> Yup I figured that out ...
> but how do I do a typecast when I have the class name in a String
> variable during runtime. (I do NOT know the class name to typecast).
Yup I figured that out ...
but how do I do a typecast when I have the class name in a String
variable during runtime. (I do NOT know the class name to typecast).
On Thu, 4 Nov 1999, Nathan Meyers wrote:
> Nathan Meyers wrote:
> > SABYASACHI S GUPTA wrote:
> > >
> > > public class saby {
> > >
Yup I figured that out ...
but how do I do a typecast when I have the class name in a String
variable during runtime. (I do NOT know the class name to typecast).
On Thu, 4 Nov 1999, Nathan Meyers wrote:
> Nathan Meyers wrote:
> > SABYASACHI S GUPTA wrote:
> > >
> > > public class saby {
> > >
SABYASACHI S GUPTA wrote:
>
> I dont know this might be something very simple...
> so please excuse me.
>
> I have the following small code.
>
> public class saby {
>
> public static void main(String args[])
> {
>
> String s = "myclass";
> Class
SABYASACHI S GUPTA wrote:
>
> Now I get the compilation error that method is not there in Object.
> So now if I want to call the method of the newly created instance
> what should I do...
>
Cast it.
((myclass) b).method()
-
SABYASACHI S GUPTA wrote:
>
> I dont know this might be something very simple...
> so please excuse me.
>
> I have the following small code.
>
> public class saby {
>
> public static void main(String args[])
> {
>
> String s = "myclass";
> Class
> I have the following small code.
>
> public class saby {
>
> public static void main(String args[])
> {
>
> String s = "myclass";
> Class c = new Class();
> try {
>
> c = Class.forName(s);
>
>
I dont know this might be something very simple...
so please excuse me.
I have the following small code.
public class saby {
public static void main(String args[])
{
String s = "myclass";
Class c = new Class();
try {
10 matches
Mail list logo