如何使用 Java 中的 instanceof 运算符?
instanceof 运算符仅用于对象引用变量。运算符检查对象是否是特定类型(类类型或接口类型)。
示例
public class Test {
public static void main(String args[]) {
String name = "James";
boolean result = name instanceof String;
System.out.println(result);
}
}输出
true
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
安卓
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP