Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Write a java program with eclipse to judge whether two integer arrays are the same, regardless of the order. Array methods cannot be used.
Write a java program with eclipse to judge whether two integer arrays are the same, regardless of the order. Array methods cannot be used.
Judge the length first. The length before comparison is equal.

1. Simple point: two for loops, nested. Set up a flag. The final setting of the default fasle loop is true; Compare one by one. Once the difference is found, break the two cycles directly. Finally, judge whether they are equal according to the flag.

2. Regardless of the same order ... use the set ... to convert the values of two arrays into strings (the strings change because the strings are rewritten equal to) and fill them all in the set. (hashset is fine), and then call Containsall () to each other; If they are all true, it is the same.