I have 3 files to test this.
//A.java
public class A {
public void method(){
System.out.println("In A");
}
}
//B.java
public class B extends A {
public void method()
{
System.out.println("hello world");
}
}
//mymain.java
In java explicit typecasting is allowed. Now if I have
1. Instance of Base class
2. Name of derived class
Can I call a method of a derived class object through the base
class instance.
theComponentApp = selAppComp[i].getInstance(); //Base class instance.
try{
String compName = selApp
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:
> > >
>
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:
> > >
>
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 {