How to judge a class is not specified the type of class?

Category: Java SE
 
zhuzhu5288
2012-12-21 01:12:42

Sponsored Links
class ClassValidator
{
private String className;
public ClassValidator (String className) {
this.className = className;
}
public void validate () throws ValidationException
{

try
{
Class.forName (this.className);
}
catch (ClassNotFoundException ex)
{

}
}

Sponsored Links

sunkai6815
2012-12-21 01:23:13
what you want to achieve in the end, did not understand.
If you want to determine whether an object property of a class can use instanceof keyword Yeah
String a = "abc";
if (a instanceof String)
bar126
2012-12-21 01:38:28
instanceof
jm123123123
2012-12-21 01:51:06
So I wrote a method can determine the class exists or not is not?
--------------- ------
Yes
tianya9413
2012-12-21 01:59:28
IsKindOf
yjjcfd
2012-12-21 02:10:34
instanceof
nemstar
2012-12-21 02:25:53
So I wrote a method can determine the class exists or not is not?
yi0104
2012-12-21 02:30:01
JAVA, wrong door, sorry.
S090101016
2012-12-21 02:49:18
Where do you want to go?
Domain and server ip had changed since 8/23/2013. Suspend the user registration and posts for program maintenance.