title: Input name of a U.S. state - Output the abbreviation. Is there a better way to write this?
body: <p>this is my very first post ever here.
  I am VERY new at programming, started learning java like a week ago, but its very exciting so far.</p>
  
  <p>I would like to hear your feedback on this code.
  Basically i want it to output the abbreviation of the state name, after inputting the name and visa versa...</p>
  
  <p>Is there a more efficient way to write this? (Efficient as in least time for the machine to process the code)</p>
  
  <pre><code>import java.util.Scanner;
  
  class apples2{
  
  
      public static void main(String[] args){
  
          Scanner inputStateName = new Scanner(System.in);
  
          System.out.println("Input the state name or abbreviation: ");
  
          String stateName = inputStateName.nextLine();
  
          for(int counter = 0; counter &lt;= statedata.states.length; counter++){
  
              if(stateName.equalsIgnoreCase(statedata.states[counter])){
                  System.out.println("The abbreviation of your state is: " + statedata.statesAb[counter]);
  
                  break;
              }
  
              if(stateName.equalsIgnoreCase(statedata.statesAb[counter])){
                  System.out.println("You've entered an abbreviation, the state for that is: " + statedata.states[counter]);
                  break;
              }
          }
      }
  }
  </code></pre>
  
  <p>"statedata.states" is an array of all state names in another class and "statedata.statesAb" is an array of the abbreviations.</p>