在单维数组中测试null [英] testing for null in a single dimensional array

查看:57
本文介绍了在单维数组中测试null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何在单维字符串数组中测试空值?

解决方案


我们如何测试单维字符串数组中的空值?



使用for语句*循环遍历数组,并使用==运算符比较数组中的每个元素。


* http://java.sun。 com / docs / books / tutor ... bolts / for.html



我们如何测试空值单维字符串数组?






只有字符串数据类型接受空值。整数或字符不接受空值。要在字符串数据类型中测试空值,只需在下面的条件中使用==运算符,


if(str [3] == null)

{


}

谢谢,






只有String数据类型接受空值。整数或字符不接受空值。要在字符串数据类型中测试空值,只需在下面的条件中使用==运算符,


if(str [3] == null)

{


}

谢谢,



不太好。只有对象可以指向空引用,而java.lang.Integer是一个Object。你可能意味着 int ,这是真的:就像任何其他原始数据类型*一样,它不能指向 null。


* http://java.sun。 COM /文档/书籍/导师... datatypes.html


how do we test for null values in single dimensional string array?

解决方案

how do we test for null values in single dimensional string array?

Loop through the array using a for statement*, and compare each element in the array using the == operator.

* http://java.sun.com/docs/books/tutor...bolts/for.html


how do we test for null values in single dimensional string array?

Hi,

Only String data type accepts null value. Integer or character does not accept null values. To test null value in string data type just use == operator in if condition like below,

if(str[3] == null)
{

}
Thanks,


Hi,

Only String data type accepts null value. Integer or character does not accept null values. To test null value in string data type just use == operator in if condition like below,

if(str[3] == null)
{

}
Thanks,

Not quite. Only Objects can point to a null reference, and java.lang.Integer is an Object. You probably mean an int, which is true: just like any other primitive data type*, it cannot point to null.

* http://java.sun.com/docs/books/tutor...datatypes.html


这篇关于在单维数组中测试null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆