Creating a loop statement to recieve a value based on a letter -


is recommended use for-each loop statement print out values (things) based on first letter? example "a" = apple, airplane. can continue statement used?

package class_inclass0920a;  public class main {      public static void main(string[] args) {         //declare array of strings         string[] things;         things = new string[] {"apple", "airplane", "car", "football","house", "aluminum"};          (int i=0; < things.length; i++) {}     } } 

there simple way handle this:

public class running {  public static void main(string[] args) {     // declare array of strings     string[] things;     things = new string[] { "apple", "airplane", "car", "football",             "house", "aluminum" };      (int = 0; < things.length; i++) {         if(things[i].startswith("a")) {             system.out.println(things[i]);         }     } } 

}

output:

apple airplane aluminum 

you can handle different conditions using technique.


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -