title: java-how to return multiple values in an array in switch case
body: <p>I want to return all the array elements which satisfies the if statement in the code above.</p>
  
  <p>Here the output is all the first element which satisfies the if condition. </p>
  
  <pre><code>switch(ch) {
       case 1: {
          g = prob1 * totoutcome;
          flag = (int) g;
          for(int i=0; i&lt;9; i++) {
               if(a1[0][0].equals(veh[i]) &amp;&amp; flag &gt; 0) {  
                flag--;
                return(id[i] + " " + name[i] + " " + number[i] + " " + veh[i] + " " + color[i] + " " + type[i] + "\n");
               }
       }
       break;
  }
  </code></pre>