title: How to have a switch case scenario using String as condition?
body: <p>I have a String that I need to get the last digit from and use switch cases according to that character.</p>
  <pre><code>String securityNumber= &quot;4561&quot;;
  String lastDigit = securityNumber.substring(securityNumber.length()-1);
  
  switch (lastDigit) {
      case &quot;0&quot;: System.out.println(&quot;0&quot;);
          break;
      case &quot;1&quot;: System.out.println(&quot;1&quot;);
          break;
      case &quot;2&quot;: System.out.println(&quot;2&quot;);
          break;
      case &quot;3&quot;: System.out.println(&quot;3&quot;);
          break;
      case &quot;4&quot;: System.out.println(&quot;4&quot;);
          break;
      default: System.out.println(&quot;def&quot;);
  }
  </code></pre>
  <p>I am getting the &quot;def&quot; as a result but should be &quot;1&quot;.</p>
  <p>What am I doing wrong? How can I have a case scenario for each of the digits from an input of String &quot;securityNumber&quot;?</p>