could any please tell me the equivalent of "TypeOf" keyword in .NET in JAVA
Thanksin ADV
Kasha
-
equivalent of "TypeOf" keyword of .NET in JAVA (3 messages)
- Posted by: Kasha Naveen
- Posted on: January 11 2006 06:36 EST
Threaded Messages (3)
- equivalent of "TypeOf" keyword of .NET in JAVA by Hugues Ferland on January 11 2006 09:17 EST
- equivalent of "TypeOf" keyword of .NET in JAVA by Krishna Pothula on January 14 2006 04:48 EST
- Did you try instanceof by Sal Branco on April 17 2008 09:49 EDT
-
equivalent of "TypeOf" keyword of .NET in JAVA[ Go to top ]
- Posted by: Hugues Ferland
- Posted on: January 11 2006 09:17 EST
- in response to Kasha Naveen
The equivalent to the TypeOf keyword is the class literal as defined here.
You can also use the getClass() instance method to obtain the Class of a specific object.
public class MyClass
{
public int intI;
public void MyMeth()
{
}
public static void main(String[] arg)
{
Class c = MyClass.class;
// alternatively, you could use
MyClass t1 = new MyClass();
Class c2 = t1.getClass();
Method[] methods= c.getMethods();
....
Field[] field= c.getFields();
....
}
}
For more info on the java.lang.Class type, look at the JavaDoc for your JDK. -
equivalent of "TypeOf" keyword of .NET in JAVA[ Go to top ]
- Posted by: Krishna Pothula
- Posted on: January 14 2006 04:48 EST
- in response to Kasha Naveen
In simple terms if...
in .NET
setDBColumn("ColName", TypeOf(String));
then in Java
setDBColumn("ColName", String.class); -
Did you try instanceof[ Go to top ]
- Posted by: Sal Branco
- Posted on: April 17 2008 09:49 EDT
- in response to Kasha Naveen
Try instanceof in java to getsomewhat equivalent for it.