把test.java救回来了

This commit is contained in:
2024-06-11 01:53:01 +08:00
parent d085000064
commit d753356d40
54 changed files with 1309 additions and 1297 deletions
+35 -35
View File
@@ -1,35 +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 *********/
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 *********/