Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your variable names indicate a major code smell. It sounds like instead of having six variables, you should instead have two arrays, each containing three strings. In other words, something like this initially would have been much better:</p> <p><pre><code>String[][] strs = new String[2][3]; strs[0][0] = str11; strs[0][1] = str12; ...</pre></code></p> <p>Chances are that depending where you obtained the six strings from, you will not need to do this manually immediately before the comparison, but can likely pass in your arguments in a format that is more friendly.</p> <p>If you do wish to do this by comparing arrays of the string objects, and you are using Java 1.5 or above, remember that you have access to the java.util.Arrays.equals() methods for array equality. Using library methods as much as possible is a great way to avoid extra effort reinventing the wheel, and possible implementation mistakes (both submitted implementations so far have bugs, for example).</p> <p>The exact route you take probably depends on the domain you are writing for - if your particular problem requires you to always compare 3-tuples, then writing the code to explictly compare groups of three strings would not be such a good idea, as it would probably be more immediately understandable than code that compared arrays of arbitrary length. (If you are going this route, then by all means us a single if() conditional with &amp;&amp; instead of nested if blocks, as Adam Bellaire demonstrated).</p> <p>In general though, you'll have a much more reuable block of code if you set it up to work with arrays of arbitrary length.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload