下面的代码应该抛出异常
import jakarta.annotation.Nonnull;
public class test89 {
public String processString(@Nonnull String input) {
// Your method logic here
return "Processed: " + input;
}
public static void main(String[] args) {
test89 exampleService = new test89();
String result = exampleService.processString(null);
System.out.println(result);
}
}
但输出为
`
Processed: null
Process finished with exit code 0`
它应该抛出异常
在你的小代码示例中,注释处理应该发生在哪里?
您不使用依赖项注入或调用任何验证,因此您的代码按照我的预期工作。
注释本身不执行任何操作,它只是其他代码要处理的标记。