Download Exception_project/Exception_module/src/Exception_package1/Student.java from zxy0307/Java: direct link, hf CLI and curl.
- Browser
- Download file 987 Bytes
-
https://huggingface.co/zxy0307/Java/resolve/main/Exception_project/Exception_module/src/Exception_package1/Student.java
- Command line
-
hf download hf://zxy0307/Java/Exception_project/Exception_module/src/Exception_package1/Student.java
-
curl -L -o Student.java https://huggingface.co/zxy0307/Java/resolve/main/Exception_project/Exception_module/src/Exception_package1/Student.java
987 Bytes
| package Exception_package1; | |
| public class Student { | |
| private String name; | |
| private int age; | |
| public Student(String name, int age) { | |
| this.name = name; | |
| this.age = age; | |
| } | |
| public Student() { | |
| } | |
| public Student(String str) { // "张三,23" | |
| String[] arr = str.split(","); | |
| this.name = arr[0]; | |
| this.age = Integer.parseInt(arr[1]); | |
| } | |
| public String getName() { | |
| return name; | |
| } | |
| public void setName(String name) { | |
| this.name = name; | |
| } | |
| public int getAge() { | |
| return age; | |
| } | |
| public void setAge(int age) { | |
| if (age < 18 || age > 40) { | |
| //System.out.println("年龄超出范围"); | |
| throw new RuntimeException(); | |
| } else { | |
| this.age = age; | |
| } | |
| } | |
| public String toString() { | |
| return "Student{" + | |
| "name='" + name + '\'' + | |
| ", age=" + age + | |
| '}'; | |
| } | |
| } | |