java - How to check multiple variables at once? -


Is it possible to check all to write a block of code, or all the objects / variables of a particular type For a certain specialty? (Without having to enter a statement for each) - then set it to right or false things.


As you had 3 variables and ...

  if (a = 0 || b = 0 || c = 0) {// Set any variable to minus 4}   

The action described in the preform comment


Or, for a complex example, 4 arraylists of type integer:

  from the list & lt; Integer & gt; Even new = ArrayList & LT; Integer & gt; (), // Positive also ints strange = new ArrayList & LT; Integer & gt; (), // positively weird ints negaodd = new ArrayList & lt; Integer & gt; () // Negatives also ints negaeven = new ArrayList & LT; Integer & gt; (); // Negative weird ints   

Anything like that:

  Whatever the test array is being if ("AnyArray" .isEmpty ()) {/ Tried = null; }   

So it is that if any of the arrays are being emptied, then instead of [], they will return "null".

Hmmm, if you want to make something more interesting, then simply repetition the collection, it looks very functional to implement a filter and apply the map. Try Lamb's or Google Collections (see here for a good post). Here is an example using the vertical.
  list & lt; Integer & gt; Strange number = filter (weird, asList (1, 2, 3, 4, 5));   

For more potential ideas see here:

Disclaimer Sometimes falling into the water with this kind of thing (when a Simple loop will suffice) obfuscates code over anything, so be careful.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -