代码拉取完成,页面将自动刷新
package basic.c09_exceptions;
/*
Clase 8 - Manejo de excepciones, depuración y extras (28/05/2025)
Vídeo: https://www.twitch.tv/videos/2471305243
*/
public class ThrowExample {
public void checkAge(int age) throws IllegalArgumentException {
if (age < 18) {
throw new IllegalArgumentException("Tienes que ser mayor de edad");
} else {
System.out.println("Es mayor de edad");
}
}
public void checkScore(int score) throws CustomException {
if (score < 0 || score > 100) {
throw new CustomException("La puntuación debe estar entre 0 y 100");
} else {
System.out.println("Puntuación válida: " + score);
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。