用java写个如下程序:这个同学的姓名是:小明 年龄是25 工作了3年了 做过5个项目 技术方向是java 兴趣爱好是篮球
时间: 2023-06-24 21:08:33 浏览: 100
```java
public class Student {
private String name;
private int age;
private int workYears;
private int projectNum;
private String techDirection;
private String hobby;
public Student(String name, int age, int workYears, int projectNum, String techDirection, String hobby) {
this.name = name;
this.age = age;
this.workYears = workYears;
this.projectNum = projectNum;
this.techDirection = techDirection;
this.hobby = hobby;
}
public String getName() {
return name;
}
public int getAge() {
return age;
}
public int getWorkYears() {
return workYears;
}
public int getProjectNum() {
return projectNum;
}
public String getTechDirection() {
return techDirection;
}
public String getHobby() {
return hobby;
}
public static void main(String[] args) {
Student xiaoming = new Student("小明", 25, 3, 5, "Java", "篮球");
System.out.println("这个同学的姓名是:" + xiaoming.getName());
System.out.println("年龄是:" + xiaoming.getAge());
System.out.println("工作了" + xiaoming.getWorkYears() + "年了");
System.out.println("做过" + xiaoming.getProjectNum() + "个项目");
System.out.println("技术方向是:" + xiaoming.getTechDirection());
System.out.println("兴趣爱好是:" + xiaoming.getHobby());
}
}
```
输出结果:
```
这个同学的姓名是:小明
年龄是:25
工作了3年了
做过5个项目
技术方向是:Java
兴趣爱好是:篮球
```
阅读全文