在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


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

查看所有标签

猜你喜欢:

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

Chinese Authoritarianism in the Information Age

Chinese Authoritarianism in the Information Age

Routledge / 2018-2-13 / GBP 115.00

This book examines information and public opinion control by the authoritarian state in response to popular access to information and upgraded political communication channels among the citizens in co......一起来看看 《Chinese Authoritarianism in the Information Age》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

随机密码生成器
随机密码生成器

多种字符组合密码