Java how to compare an element of an array with all the other elements of the same array -


Assume that we have the integer element x [N]. How can I know that for example the X [1] element is equal to or equal to all the other elements of the same array? I have used a four-loop but it does not work because I want to check whether any other element is more than an element to do something else. If I use it for this, instead, if the element is more than one of the other elements, then it does something, and this is wrong for my purposes. Please help me, can you help me?

Here's an example of me:

 for  (int i = 0; i & lt; num & amp; i! = J; i ++) {if (ElementiInseriti [j] & gt; = elementiInseriti [i]) do something; }}  

Use a boolean variable

  Boolean doSomething = true; For (Int I = 0; i & lt; num & amp;; some; i ++) {if (elementiInseriti [j] & lt; elementiInseriti [i]) {doSomething = false; }} If (doSomething) // do something  

If elementiInseriti [j] is less than any of the other elements, the flag will lie, and you do not have anything will do.


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -