Answer the question
In order to leave comments, you need to log in
Why doesn't it output an empty array?
The bottom line is that if a null string is passed as an argument, then you need to display an empty array, but it is not displayed, what's the matter?
public static char[] removeLetter(String arg) {
if(arg == null) {
return arg.toCharArray();
}
String x = arg.toLowerCase().replace('r','!');
char[] array = x.toCharArray();
return array;
}
Answer the question
In order to leave comments, you need to log in
At you in this place 100% NullPointerException. In Java, you can't call methods on null references. You can create an array by hand: new char[0]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question