I want check the variable type. How do I do that? For e.g
if (num is of String type )
{This must be executed}
I'm currently using Java 17. Any suggestions?
I want check the variable type. How do I do that? For e.g
if (num is of String type )
{This must be executed}
I'm currently using Java 17. Any suggestions?
You can use instanceof String
to check whether a variable is a String.
if (num instanceof String) {
// code to be executed
}