How to check type of variable in Java?

前端 未结 14 1507
别跟我提以往
别跟我提以往 2020-11-28 05:14

How can I check to make sure my variable is an int, array, double, etc...?

Edit: For example, how can I check that a variable is an array? Is there some function to

14条回答
  •  有刺的猬
    2020-11-28 06:03

    You can check it easily using Java.lang.Class.getSimpleName() Method Only if variable has non-primitive type. It doesnt work with primitive types int ,long etc.

    reference - Here is the Oracle docs link

提交回复
热议问题