title: Checking the end of a string in Java multiple times?
body: <p>So in Java, I know that <code>str.endsWith(suffix)</code> tests if str ends with something. Let's say I have a text with the line "You are old" in it. How would I take the "old" and set it as a variable so I can print it out in the console?</p>
  
  <p>I know I could do: </p>
  
  <pre><code>if(str.endsWith("old")){ 
     String age = "old";
  }
  </code></pre>
  
  <p>But then I'm going to have more options, so then I'd have to do:</p>
  
  <pre><code>if(str.endsWith("option1")){ 
     String age = "option1";
  }
  
  if(str.endsWith("option2")){ 
     String age = "option2";
  }
  
  ...
  </code></pre>
  
  <p>Is there a more efficient and less verbose way to check the end of strings over writing many, possibly hundreds, of if statements</p>
  
  <pre><code>Format:
      setting: option
      setting2: option2
      setting3: option3 ...
  </code></pre>
  
  <p>Regardless of what "option" is, I want to set it to a variable.</p>