File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
src/main/java/com/thealgorithms/conversions Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -66,12 +66,16 @@ private static int romanSymbolToInt(final char symbol) {
6666 * @param roman the Roman numeral string
6767 * @return the integer value of the Roman numeral
6868 * @throws IllegalArgumentException if the input contains invalid Roman characters
69+ * @throws NullPointerException if the input is {@code null}
6970 */
7071 public static int romanToInt (String roman ) {
72+ if (roman == null ) {
73+ throw new NullPointerException ("Input cannot be null" );
74+ }
75+
7176 roman = roman .toUpperCase ();
7277 int sum = 0 ;
7378 int maxPrevValue = 0 ;
74-
7579 for (int i = roman .length () - 1 ; i >= 0 ; i --) {
7680 int currentValue = romanSymbolToInt (roman .charAt (i ));
7781 if (currentValue >= maxPrevValue ) {
You can’t perform that action at this time.
0 commit comments