How to check null element if it is integer array in Java? -
I am quite new to Java and there is a problem checking the zero element in an integer array. I am using Eclipse for the editor and the line error checking error element is showing:
if (a [i]! = Null) {< Code> Error message from Eclipse:
operator! = For logic type is mandatory int, null
In PHP, it works without problems, but in Java, it seems that I want to type orange the object from integer Change so that do not complain to the line (like below)
Object [] A = new object [3];
So my question is that I still want to declare the integer array and still want to do a redundancy check, what is the syntax for it?
Code:
Public Zero Test () {int [] a = New Int [3]; (Int i = 0; i & lt; a.length; i ++) {if (a [i]! = Null) {// This line is compliant ... system.out.println ('null ! '); Java can not contain a int
primitive type and null
. Objects, however, are stored in the form of references, so if you declare an object reference but do not object to any new
, the reference will be null
. integers
with the object rappers ints
, which means that they can be null
.
public zero test () {integer [] a = new integer [3]; For (int i = 0; i & lt; a.length; i ++) {if (a [i]! = Null) {// Now should compile the system.out.println ('null!') ; }}}
Comments
Post a Comment