Hi there, apologies if this is a very basic question, new to Java. I've been trying to take Roman numerical input and convert to Arabic, and in doing so have been attempting to run through all the "digits" in a roman numeral string, adding (or subtracting) their values. I've been using the following conditions for a for loop
for (int x=0; x<=number.length(); x++)
where number is inputted from the console. This made sense to me, but I'm getting the following error message
Exception in thread "main" Mjava.lang.StringIndexOutOfBoundsException: String index out of range: [!!!]
at java.lang.String.charAt(String.java:686)
at Q3_6_a.main(Q3_6_a.java:106)
where the underlined part is the length of the string inputted. Does anyone know why this doesn't work, and if there's any way to use a variable string length as an upper bound for the index in a loop? As far as I can see this problem is solely due to the limit, not to the action of the for loop.
Thanks