• Post Reply Bookmark Topic Watch Topic
  • New Topic

Equivalent Arrays, comparing 2 user inputs to determine if same  RSS feed

 
Francais Libble
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have been stuck on this for the past 2 hours, basically we have to compare user input, put user input into an array and compare for equivalency.
an example of the program:

Array 1: 1 2 3 4 5 6 7 8
Array 2: 1 2 3 4 5 6 7 8
Array 3: 1 2 3 4 5 6 7 8 9
Array 4: 1 2 3 4 5 6 7 8

Array 1 & 2 are equal
Array 1 & 3 are not equal
Array 1 & 4 are not equal.

edit** this cannot be done by importing Java.util.Array at all!! (my research only find this to compare arrays ) which is why I am having trouble starting off
My code thus far: (shameful i know) I'm having a huge mind block ::

 
Stefan Evans
Bartender
Posts: 1837
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Array 1: 1 2 3 4 5 6 7 8
Array 3: 1 2 3 4 5 6 7 8 9

You say that these are not equal? Why not?

Array 1: 1 2 3 4 5 6 7 8
Array 4: 1 2 3 4 5 6 7 8

You say that these are not equal? Why not?

What are the requirements for two arrays to be 'equal'? Can you write them down?
 
Francais Libble
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stefan Evans wrote:Array 1: 1 2 3 4 5 6 7 8
Array 3: 1 2 3 4 5 6 7 8 9

You say that these are not equal? Why not?

Array 1: 1 2 3 4 5 6 7 8
Array 4: 1 2 3 4 5 6 7 8

You say that these are not equal? Why not?

What are the requirements for two arrays to be 'equal'? Can you write them down?

They condition for the arrays to be equal is that they have to be equal word for word

edit** Sorry i realize my original post has a typo!
 
Junilu Lacar
Sheriff
Posts: 11485
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Double check what you posted. Array 1, 2, and 4 look exactly the same. Maybe you see #TheDress as White and Gold...
 
Stefan Evans
Bartender
Posts: 1837
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> They condition for the arrays to be equal is that they have to be equal word for word

Can you be more specific? What does it mean to be equal 'word for word'
e.g. from your examples if one of your arrays is longer than the other than they are obviously not equal.

So size matters.
Does order matter? ie [1,2,3] equal to [3,2,1] ?

How do YOU determine if the arrays are the same or different? How do you point out the difference?
Write it out on paper. Honestly it really helps to clarify the process of writing a computer program.
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Francais Libble wrote: . . . this cannot be done by importing Java.util.Array . . .
You mean java.util.Arrays. That class has all sorts of methods for handling arrays, and they were all written in that class for convenience's sake.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!