Obj In array as int

M

mnml

Hi,
I am trying to make a if loop using a Int value contained in an Array
'array2D[a][a]'

if(array2D[a][a]==0)
dosomething();

I would like to know how I can define the content as an Integer in
that case;
The error message:

../myDisplay.java:52: incomparable types: java.lang.Object and int
if(array2D[a][a]==0)
^

Thanks
 
G

GArlington

Hi,
I am trying to make a if loop using a Int value contained in an Array
'array2D[a][a]'

if(array2D[a][a]==0)
dosomething();

I would like to know how I can define the content as an Integer in
that case;
The error message:

./myDisplay.java:52: incomparable types: java.lang.Object and int
if(array2D[a][a]==0)
^

Thanks

Are you trying to make a 2D array of Integer objects
Integer [][] array2D = new Integer[a];
or 2D array of int (primitive data type)
int[][] array2D = new int[a];
 
G

GArlington

Hi,
I am trying to make a if loop using a Int value contained in an Array
'array2D[a][a]'

if(array2D[a][a]==0)
dosomething();

I would like to know how I can define the content as an Integer in
that case;
The error message:

./myDisplay.java:52: incomparable types: java.lang.Object and int
if(array2D[a][a]==0)
^

Thanks

If is NOT a loop...
 
L

Lew

mnml said:
Hi,
I am trying to make a if loop using a Int value contained in an Array
'array2D[a][a]'

if(array2D[a][a]==0)
dosomething();

I would like to know how I can define the content as an Integer in
that case;
The error message:

./myDisplay.java:52: incomparable types: java.lang.Object and int
if(array2D[a][a]==0)
^
Are you trying to make a 2D array of Integer objects
Integer [][] array2D = new Integer[a];
or 2D array of int (primitive data type)
int[][] array2D = new int[a];


To the OP: Here's where an SSCCE
<http://www.physci.org/codes/sscce.html>
can be so very useful.

Notice that GArlington's question can only be answered by reference to the
code that you /didn't/ post.

An Integer or int array would've worked.

Another hint - the error message told you what was wrong. You were comparing
an Object to an int. What would have been comparable, if not Object to int?
 
M

mnml

Hi,
I am trying to make a if loop using a Int value contained in an Array
'array2D[a][a]'
if(array2D[a][a]==0)
dosomething();

I would like to know how I can define the content as an Integer in
that case;
The error message:
./myDisplay.java:52: incomparable types: java.lang.Object and int
if(array2D[a][a]==0)
^

Are you trying to make a 2D array of Integer objects
Integer [][] array2D = new Integer[a];
or 2D array of int (primitive data type)
int[][] array2D = new int[a];


thanks you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top