Java – how to check if a class exists
•
Java
Is there a static method of 'class' that can tell us whether the user input class (in the form of string) is a valid existing Java class name?
Solution
You can use class Forname checks the existence of the class as follows:
try
{
Class.forName( "myClassName" );
}
catch( ClassNotFoundException e )
{
}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
