Skip to content

Commit e3adfa4

Browse files
committed
Fix
1 parent adab3e2 commit e3adfa4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/main/java/com/thealgorithms/conversions/RomanToInteger.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff 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) {

0 commit comments

Comments
 (0)