在Java中,如何检查float变量是否为空?

栏目: Java · 发布时间: 6年前

内容简介:float是原始数据类型,而不是对象. null检查用于对象.对于基元,您应该使用默认值检查.对于float,默认值为0.0f.翻译自:https://stackoverflow.com/questions/18492432/in-java-how-do-you-check-if-a-float-variable-is-null
看来,当涉及到* value.getFloat(“Value_Quotient”,quotient_Float)== null *时,它遇到了一个问题.我该如何解决?
private void Store() {
    quotient_Float = posture_error/time;
    if(value.getFloat("Value_Quotient", quotient_Float)==null || quotient_Float < value.getFloat("Value_Quotient", quotient_Float))
    {
        editor.putFloat("Value_Quotient", quotient_Float);
        editor.commit();
    }           
}

float是原始数据类型,而不是对象. null检查用于对象.对于基元,您应该使用默认值检查.对于float,默认值为0.0f.

翻译自:https://stackoverflow.com/questions/18492432/in-java-how-do-you-check-if-a-float-variable-is-null


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Head First Design Patterns

Head First Design Patterns

Elisabeth Freeman、Eric Freeman、Bert Bates、Kathy Sierra、Elisabeth Robson / O'Reilly Media / 2004-11-1 / USD 49.99

You're not alone. At any given moment, somewhere in the world someone struggles with the same software design problems you have. You know you don't want to reinvent the wheel (or worse, a flat tire),......一起来看看 《Head First Design Patterns》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具