在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


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

查看所有标签

猜你喜欢:

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

Web Design Handbook

Web Design Handbook

Baeck, Philippe de 编 / 2009-12 / $ 22.54

This non-technical book brings together contemporary web design's latest and most original creative examples in the areas of services, media, blogs, contacts, links and jobs. It also traces the latest......一起来看看 《Web Design Handbook》 这本书的介绍吧!

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

在线压缩/解压 JS 代码

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码