• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Equivalent Arrays, comparing 2 user inputs to determine if same

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ::

 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Sheriff
Posts: 17652
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 79401
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic