title: IndexOutOfBoundsException, no clear cause
body: <p>this is probably a really simple problem, but I can't figure out where I went wrong. This is a homework problem, but I've worked through the logic, I just seem to be missing a small detail with my syntax or something, and it's causing issues.</p>
  
  <pre><code>import java.util.*;
  
  public class RomanNumeral{
      private String romanInput;
      private int decimalValue;
      public boolean check;
      private int tester;
      private static final Hashtable&lt;Character, Integer&gt; converter = new Hashtable&lt;Character, Integer&gt;();{
      RomanNumeral.converter.put('I',1);
      RomanNumeral.converter.put('V',5);
      RomanNumeral.converter.put('X',10);
      RomanNumeral.converter.put('L',50);
      RomanNumeral.converter.put('C',100);
      RomanNumeral.converter.put('D',500);
      RomanNumeral.converter.put('M',1000);
      }
  
      public RomanNumeral(String romanInput){
      this.romanInput = romanInput;
      }
  
      /**
       * @return the roman numeral
       */
      public String getRoman() {
          convertRoman(romanInput);
          return romanInput;
      }
  
      /**
       * @return the decimal form of the numeral
       */
      public int getDecimal() {
          convertRoman(romanInput);
          return decimalValue;
      }
  
      private void isValid(String romanInput){
          tester=0;
          for(int i = 0; i &lt; romanInput.length(); i++) { //this test detects invalid characters
              char letter = romanInput.charAt(i);
              if(converter.containsKey(letter)){
                  tester += 1;
              }
              else {
              }
          }
          check = (tester==romanInput.length());
  
      }
  
      //go character by character to convert the number (converter.lookup() would be better, but requires all cases be present in the Hash table (as far as I know))
      private void convertRoman(String romanInput){
          isValid(romanInput);
          if(check){
              decimalValue = 0;
              for(int i = 0; i &lt; romanInput.length(); i++) {
                  char letter = romanInput.charAt(i);
                  int n = (int) converter.get(letter);
                  if(i &lt; romanInput.length()){
                      if(n &lt; ((int)converter.get(romanInput.charAt(i+1)))){
                          decimalValue -= n;
                      }
                      else {
                          decimalValue += n;
                      }
                  }
                  else {
                      decimalValue += n;
                  }
              }
          }
          else{
              decimalValue = 0;
              this.romanInput = "Invalid Roman Numeral";
          }
      }
  }
  </code></pre>
  
  <p>When I run this code using getRoman("IV") or any other roman numeral, I get the following:</p>
  
  <pre><code>Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 1
      at java.lang.String.charAt(Unknown Source)
      at RomanNumeral.convertRoman(RomanNumeral.java:61)
      at RomanNumeral.getRoman(RomanNumeral.java:26)
  </code></pre>
  
  <p>Could I get a pointer as to what's wrong? I remembered to limit my index to the length of the string, not sure what I'm missing.</p>
  
  <p>EDIT: I recognize that my stack trace points to line 61. I already made the line before check to make sure that i is less than the length of the string I'm indexing. What else can I check to make this work?</p>