How to check if the class name is valid?
class, java, methods
Solution
`SourceVersion.isName` can be used to check fully qualified names.
If no `.`s should be allowed, the check can be done this way:
boolean isValidName (String className) {
return SourceVersion.isIdentifier(className) && !SourceVersion.isKeyword(className);
}
Problem
Is there a method in Java to check if a string can be used as a class name?