We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent adab3e2 commit e3adfa4Copy full SHA for e3adfa4
src/main/java/com/thealgorithms/conversions/RomanToInteger.java
@@ -66,12 +66,16 @@ private static int romanSymbolToInt(final char symbol) {
66
* @param roman the Roman numeral string
67
* @return the integer value of the Roman numeral
68
* @throws IllegalArgumentException if the input contains invalid Roman characters
69
+ * @throws NullPointerException if the input is {@code null}
70
*/
71
public static int romanToInt(String roman) {
72
+ if (roman == null) {
73
+ throw new NullPointerException("Input cannot be null");
74
+ }
75
+
76
roman = roman.toUpperCase();
77
int sum = 0;
78
int maxPrevValue = 0;
-
79
for (int i = roman.length() - 1; i >= 0; i--) {
80
int currentValue = romanSymbolToInt(roman.charAt(i));
81
if (currentValue >= maxPrevValue) {
0 commit comments