Home > Back-end >  JAVA beginners beg to solve!
JAVA beginners beg to solve!

Time:10-02

How to print out the two dimensional array in the same Numbers,

CodePudding user response:

The great god out walk??

CodePudding user response:

The great god out walk??

CodePudding user response:

1, 2 layer for loop traverse judgment
2, merge the two arrays and then into the set
 
Set the Set=new HashSet ();
For (int element: array) {
//set to add is not repeating elements
if (! Set. The add (element)) {
System. Out.println (" get repeating element ")
}
}

CodePudding user response:

reference it dog _ reply: 3/f
1, 2 layer for loop traverse judgment
2, merge the two arrays and then into the set
 
Set the Set=new HashSet ();
For (int element: array) {
//set to add is not repeating elements
if (! Set. The add (element)) {
System. Out.println (" get repeating element ")
}
}

I think maybe I express has a problem, I want to ask is how to print out the same number number they, and not repeat, for example, the two Numbers 123447 and 12257 how to print out the 127

CodePudding user response:

The first set of Numbers directly into the set, judging from a second set of Numbers, existing in the setResult collection

if (! Set. The add (element)) {
SetResult. Add (element);
}
  • Related