Steffan Harris
Steffan Harris

Reputation: 9326

Comparing an array and arrayList indexes

I was wondering if there was any way that i could compare and index of an arrayList and a array. I tried using the > operator and that didn't work.

I have tried something like this

if(ArrayVar[i] > arrayList.get(i) )

and i get errors.

Upvotes: 0

Views: 1132

Answers (1)

Starkey
Starkey

Reputation: 9781

You say that the array is of type Object and the arrayList is an Integer type. You are comparing apples and oranges.

Assuming the array acutally holds Integers as their Objects, you can cast that to an Integer and do the comparison then.

If the array doesn't have Integers (or any kind of number) how do you expect to compare them?

Upvotes: 2

Related Questions