Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.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?_Java - Fatal编程技术网

必需变量找到值java?

必需变量找到值java?,java,Java,我一直在为班级编写一个比较两个临时值的程序。我所有的东西都在工作,但是在我的最后一个方法中,我得到了一个错误,即使它是完全一样的。is not equal to函数表示所需变量找到值且不会运行,即使以相同方式构建的其余变量也会运行 public boolean isLessThan(Temperature t){ return t.get()>this.get(); } public boolean isGreaterThan(Temperature t){ return

我一直在为班级编写一个比较两个临时值的程序。我所有的东西都在工作,但是在我的最后一个方法中,我得到了一个错误,即使它是完全一样的。is not equal to函数表示所需变量找到值且不会运行,即使以相同方式构建的其余变量也会运行

 public boolean isLessThan(Temperature t){

 return t.get()>this.get();
 }
 public boolean isGreaterThan(Temperature t){
    return t.get()>this.get();
 }
 public boolean isEqual(Temperature t){
    return (Math.abs(this.get()-t.get()))<=10E-12;

 }

 public boolean isGreaterThanOrEqual(Temperature t){
     return t.get()>=this.get();

 }
 public boolean isLessThanorEqual(Temperature t){
     return (t.get()<=this.get());}

 public boolean isNotEqualTo(Temperature t){
    return Math.abs(this.get()-t.get())=>10E-12;
 }



}
公共布尔值小于(温度t){
返回t.get()>this.get();
}
公共布尔值大于(温度t){
返回t.get()>this.get();
}
公共布尔值相等(温度t){
return(Math.abs(this.get()-t.get())=this.get();
}
公共布尔值isLessThanorEqual(温度t){
返回(t.get()10E-12;
}
}
此处显示您的语法

return Math.abs(this.get()-t.get())=>10E-12;
(假设您希望大于或等于)需要

return Math.abs(this.get()-t.get()) >= 10E-12;
还有这个

public boolean isLessThan(Temperature t){
  return t.get()>this.get();
}
应该是

public boolean isLessThan(Temperature t){
  return t.get() < this.get();
}
公共布尔值小于(温度t){
返回t.get()
此处显示您的语法

return Math.abs(this.get()-t.get())=>10E-12;
(假设您希望大于或等于)需要

return Math.abs(this.get()-t.get()) >= 10E-12;
还有这个

public boolean isLessThan(Temperature t){
  return t.get()>this.get();
}
应该是

public boolean isLessThan(Temperature t){
  return t.get() < this.get();
}
公共布尔值小于(温度t){
返回t.get()
嗯……操作员错了

<= // less or equal
>= // bigger or equal
=//更大或相等

嗯……操作员错了

<= // less or equal
>= // bigger or equal
=//更大或相等

所以我的教授有一个测试程序,它检查了我所有的方法,告诉我哪些是错误的,它比较了两个相同的值,其中一个是真的,另一个是假的,它们应该都是真的还是都是假的。你知道是什么原因吗?我注意到isnotequalto在测试中有一个等号。So我的教授有一个测试程序,它检查了我所有的方法,告诉我哪些是错误的,它比较了两个相同的值,其中一个是真的,另一个是假的,它们应该都是真的还是都是假的。有什么想法会导致这种情况吗?我注意到isnotequalto在测试中有一个等号。