Hi everyone I'm trying to write a program to convert from roman numerals to Arabic numerals. However, I keep having issues with StringIndexOutOfBoundsException: String index out of range: -1. below is my code
package com.company;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        System.out.println(romanToArabic("CIV"));
    }
    public static int romanToArabic(String romanNumeral){
        Map <Character, Integer> map = new HashMap<>();
        map.put('I', 1);
        map.put('V', 5);
        map.put('X', 10);
        map.put('L', 50);
        map.put('C', 100);
        map.put('D', 500);
        map.put('M', 1000);
        int result = 0;
        for (int i=0; i < romanNumeral.length(); i++){
            int current = map.get(romanNumeral.charAt(i));
            int next = map.get(romanNumeral.charAt(i-1));
            if (i>0 && current > next){
                result += current - 2*next;
            }
            result += current;
        }
        return result;
    }
				
                        
"i-1" is -1 when you walk through the loop for the first time (i=0)