Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>int newVariable = return methodFromWhichDataIsReturned(fieldReturnedFromMethod); </code></pre> <p>The keyword <code>return</code> cannot be placed there. It indicates that you wish to exit the method that is currently executing so it can only be placed at the beginning of a line, such as <code>return 3;</code> When you're calling a method that returns a value, there's no need to place <code>return</code> in front. In other words, it should be:</p> <pre><code>int newVariable = return methodFromWhichDataIsReturned(fieldReturnedFromMethod); </code></pre> <p>The method rollTheDice should more likely be written as:</p> <pre><code>int rollNum; int[] rolledDie = new int[DICE_TO_ROLL]; for (rollNum = 1; rollNum &lt;= DICE_TO_ROLL; rollNum++) { rolledDie[rollNum - 1] = rollADie(HIGHEST_DIE_VALUE, LOWEST_DIE_VALUE); } return rolledDie; </code></pre> <p>In the second line above, we're creating a new array with <code>DICE_TO_ROll</code> number of elements. This array has integers and each integer will be 0 by default. We're now going to roll a die and each time rollADie has computed a value, we'll store it in <code>rollADie</code> at position <code>rollNum - 1</code> (as arrays start at 0, so the first element is at <code>rolledDie[0]</code>). In the last line, we're returning the array from this method.</p> <p>Lastly, in various languages it is a convention to write the names of constants in capitals and the names of regular variables otherwise. For example, the following line:</p> <pre><code>public static int rollADie(int HIGHEST_DIE_VALUE,int LOWEST_DIE_VALUE) </code></pre> <p>would commonly be written as:</p> <pre><code>public static int rollADie(int highestDieValue, int lowestDieValue) </code></pre> <p>or:</p> <pre><code>public static int rollADie(int highest_die_value, int lowest_die_value) </code></pre>
    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.
    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