Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/202.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java android getClass b1类; b1=GS.scr\U复选框(x,y-GS.ss,本); 如果(b1.getClass().equals(BLK.class)| b1.getClass().equals(STN.class)) { 如果(b1.1==真) { scr_级联_fall(scr_check_freebox(x,y-GS.ss,this)); 返回(真); } }_Java_Android - Fatal编程技术网

java android getClass b1类; b1=GS.scr\U复选框(x,y-GS.ss,本); 如果(b1.getClass().equals(BLK.class)| b1.getClass().equals(STN.class)) { 如果(b1.1==真) { scr_级联_fall(scr_check_freebox(x,y-GS.ss,this)); 返回(真); } }

java android getClass b1类; b1=GS.scr\U复选框(x,y-GS.ss,本); 如果(b1.getClass().equals(BLK.class)| b1.getClass().equals(STN.class)) { 如果(b1.1==真) { scr_级联_fall(scr_check_freebox(x,y-GS.ss,this)); 返回(真); } },java,android,Java,Android,函数“scr_get_freebox”搜索BLK和STN的所有实例,并返回它找到的第一个实例,该实例全部或部分存在于一个框中,框的左上角是您传递的坐标,但它将从它的搜索中排除您传递的“this”。除了返回null或BLK实例或STN实例之外,这并不重要 在第5行给出错误,其中表示“如果(b1.falling==true)” 问题是,这两个类(BLK和STN)都有一个名为falling的布尔变量。编译器只是在这里装聋作哑 我如何消除这个错误?使用getClass()或instanceof是否有特殊

函数“scr_get_freebox”搜索BLK和STN的所有实例,并返回它找到的第一个实例,该实例全部或部分存在于一个框中,框的左上角是您传递的坐标,但它将从它的搜索中排除您传递的“this”。除了返回null或BLK实例或STN实例之外,这并不重要

在第5行给出错误,其中表示“如果(b1.falling==true)” 问题是,这两个类(BLK和STN)都有一个名为falling的布尔变量。编译器只是在这里装聋作哑


我如何消除这个错误?使用getClass()或instanceof是否有特殊的方法?

您已将
b1
声明为
Class
。因此当然
b1.falling==true
是一个编译错误,因为
Class
没有
falling
字段

您想要的是更改
b1类
BLK
/
STN
的超类,以便在最坏的情况下,如果除了
Object
之外没有其他超类(稍后使用强制转换访问字段),它可以保存这些类的实例:


如何将一个对象转换为另一个对象?
MyObject mo=(MyObject)obj我需要一个使用Object的替换示例,因为我根据它产生的类将b1强制转换为BLK或STN,而b1.1仍然会给出一个错误。
Class<?> b1;
b1 = GS.scr_check_freebox(x, y-GS.ss, this);

if ( b1.getClass().equals(BLK.class) || b1.getClass().equals(STN.class) )
{
    if (b1.falling == true)
    {
        scr_cascade_fall(scr_check_freebox(x, y-GS.ss, this));
        return (true);
    }
}
Object b1;