📜  如何在java代码示例中检查对象类型

📅  最后修改于: 2022-03-11 14:52:11.637000             🧑  作者: Mango

代码示例1
// obj instanceof Class

/*example*/

String str = "a String made by the String class";

if(str instanceof String) System.out.println("This is True");
if(str instanceof float) System.out.println("This will never be on your screen");

// You can do this with any type of class you want!