• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help with 2d array  RSS feed

 
Jason Brody
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to search a 2D array with duplicates but it's not working properly.

 
Paul Clapham
Sheriff
Posts: 22819
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can see at least one thing in that code which is wrong. Maybe two... but I don't know what exactly it's supposed to be doing.

So why don't you start by telling us exactly what it's supposed to be doing, what it does instead, and why that's wrong.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What specific problem are you having? Note that ItDoesntWorkIsUseless(←click).
 
Paul Clapham
Sheriff
Posts: 22819
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch, Jason!
 
Jason Brody
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code is supposed to run through the 2d array and check for duplicate values. If there is a duplicate value than it should output duplicate = true. If there is not a duplicate value than is should output duplicate = false. Every number has to be unique in the array.
 
Carles Gasques
Ranch Hand
Posts: 199
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Basically you are trying to compare int[] with == and you want to compare int values.

Different dirty aproximation


Best regards,
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jason Brody wrote:I'm trying to search a 2D array

<pedant>
Can't be done - at least, not in Java. Java does not have multi-dimensional arrays - only one-dimensional arrays.

Now, and array CAN hold a reference to something (such as an array), which allows a lot of the same behavior.
</pedant>
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!