instanceof 运算符
来源:互联网 发布:wear软件安装不了 编辑:程序博客网 时间:2024/05/19 11:35
Java 中的instanceof 运算符是用来在运行时指出对象是否是特定类的一个实例。
instanceof通过返回一个布尔值来指出,这个对象是否是这个特定类或者是它的子类的一个实例。
result = object instanceof class
参数: result
必选项,任意变量。
object
必选项,任意对象表达式。
class
必选项,任意已定义的对象类。
说明:
如果 object 是 class 的一个实例,则 instanceof 运算符返回 true。如果 object 不是指定类的一个实例,或者 object 是 null,则返回 false。
public class MyHttpServlet extends MyGenericServlet {@Overridepublic void service(ServletRequest req, ServletResponse res)throws ServletException, IOException {
if(req instanceof HttpServletRequest){HttpServletRequest request = (HttpServletRequest) req;
if(res instanceof HttpServletResponse){HttpServletResponse response = (HttpServletResponse) res;Service(request,response);}}}
阅读全文
0 0
- instanceof 运算符
- instanceof运算符
- Instanceof运算符
- instanceof 运算符 小结
- instanceof 运算符
- instanceof 运算符
- instanceof 运算符 笔记
- instanceof运算符
- android instanceof 运算符
- instanceof运算符
- instanceof typeof 运算符
- instanceof 运算符
- instanceof typeof 运算符
- instanceof运算符
- instanceof运算符
- instanceof运算符
- JAVA运算符 instanceof
- php-instanceof运算符
- Android 反编译 -smali语法
- 洛谷1040 加分二叉树
- SecureRandom漏洞解析
- 哈老师抄来的比赛之心灵治愈
- python中if __name__=="__main__":
- instanceof 运算符
- Python3之基于tcp模拟ssh远程执行命令
- web——CSS中position属性( absolute 、 relative 、static 、 fixed )详解
- 进程间通信方式
- 基于springboot 之jsp章节
- android SD卡检测和热插拔功能
- 三次握手四次挥手状态
- 2017暑假第二阶段第一场 总结
- oracle 学习笔记