关于instanceof

时间:2014-07-22 23:16:12   收藏:0   阅读:284

关于instanceof ,两边类型要有关系,通常左边必有钱类型范围大,右边集成左边的类型。

1
2
3
4
5
6
7
8
public class BasicTypeTest {
    public static void main(String[] args) {
        Object test = 12;
        boolean flag = test instanceof Integer;
//      flag =  instanceof Integer;  //报错
        System.out.println(flag);
    }
}

  

关于instanceof,码迷,mamicode.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!