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) {
66
66
* @param roman the Roman numeral string
67
67
* @return the integer value of the Roman numeral
68
68
* @throws IllegalArgumentException if the input contains invalid Roman characters
69
+ * @throws NullPointerException if the input is {@code null}
69
70
*/
70
71
public static int romanToInt (String roman ) {
72
+ if (roman == null ) {
73
+ throw new NullPointerException ("Input cannot be null" );
74
+ }
75
+
71
76
roman = roman .toUpperCase ();
72
77
int sum = 0 ;
73
78
int maxPrevValue = 0 ;
74
-
75
79
for (int i = roman .length () - 1 ; i >= 0 ; i --) {
76
80
int currentValue = romanSymbolToInt (roman .charAt (i ));
77
81
if (currentValue >= maxPrevValue ) {
You can’t perform that action at this time.
0 commit comments