上传了实验六,已确认无敏感信息

This commit is contained in:
2024-06-10 16:45:13 +08:00
parent 9e11c4db21
commit 265ae65068
8 changed files with 395 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
package task2;
import java.util.Scanner;
public class Task {
/********* Begin *********/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String username = sc.next();
// 判断用户名
if (username.length() < 3) {
try {
throw new MyException("用户名小于3位Exception");
} catch (MyException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
System.out.println("用户名格式正确");
}
}
}
class MyException extends java.lang.Exception {
public MyException() {
super();
}
public MyException(String msg) {
super(msg);
}
}
/********* End *********/