Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does this while terminate before receiving a value? (java)
    primarykey
    data
    text
    <p>Here's the relevant code snippet. </p> <pre><code>public static Territory[] assignTerri (Territory[] board, String[] colors) { for (int i = 0; i&lt;board.length; i++) { // so a problem is that Territory.translate is void fix this. System.out.print ("What team controls ") ; Territory.translate (i) ; System.out.println (" ?") ; boolean a = false ; while (a = false) { String s = getIns () ; if ((checkColor (s, colors))) { board[i].team = (returnIndex (s, colors)) ; a =true ; } else System.out.println ("error try again") ; } System.out.print ("How many unites are on ") ; Territory.translate (i) ; System.out.println (" ?") ; int n = getInt () ; board[i].population = n ; } return board ; } </code></pre> <p>As an additional piece of information, <code>checkColor</code> just checks to make sure that its first argument, a string, is a string in one of the indexes of its second argument, an array. </p> <p>It seems to me that when the <code>while</code> the method gets a string from the keyboard and then only if that string checks out is a true and the <code>while</code> allowed to terminate. </p> <p>The output I get though is this: </p> <pre><code>What team controls Alaska ? How many unites are on Alaska ? </code></pre> <p>(there is space at the end to type in an input) </p> <p>This would seem to suggest that the <code>while</code> terminates before an input is ever typed in since the first line of text is within the <code>while</code> while the second line of text comes after it outside of it. </p> <p>Why is this happening? </p>
    singulars
    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.
 

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