Java 我不知道';我不明白使用“的概念;这";及;那";在爪哇

Java 我不知道';我不明白使用“的概念;这";及;那";在爪哇,java,if-statement,null,this,illegalstateexception,Java,If Statement,Null,This,Illegalstateexception,我的问题类似于以下代码,例如: public void removeSelfFromGrid() { if ( grid == null ) throw new IllegalStateException( "This actor is not contained in a grid." ); if ( grid.get( location ) != this ) throw new Illega

我的问题类似于以下代码,例如:

    public void removeSelfFromGrid()
    {
      if ( grid == null )
        throw new IllegalStateException(
              "This actor is not contained in a grid." );
      if ( grid.get( location ) != this )
        throw new IllegalStateException(
              "The grid contains a different actor at location "
                     + location + "." );

      grid.remove( location );
      grid = null;
      location = null;
    }

我很早以前就学会了,但是我不明白
这个
或者
那个
Java只有
这个
关键字,而不是
那个

意味着您正在调用的当前对象将从网格中移除
方法

使用this关键字

在实例方法或构造函数中,这是对 当前对象-正在使用其方法或构造函数的对象 打电话。您可以从中引用当前对象的任何成员 一个实例方法或构造函数

有关更多详细信息,请查看


在您的方法中,您使用了
if(grid.get(location)!=this)
,这意味着
grid
中的
位置
对象和当前对象(在其上调用
removeselfromgrid
方法)是否相同

,因此它是布尔值?像真值还是假值?@user3363511:哪个是布尔值?