JAVA高手快来救命.小弟感激不尽2..

2024年11月18日 01:46
有4个网友回答
网友(1):

我晕
我都给你写到一个类里了

public class StudentTest {
public static void main(String[] dfaa) {
Student s=new Student("王萍",'男',"英语",19);
s.setResult(1);
s.printDetails();
}
}

网友(2):

package com.bao.test;

public class Student {
private String name;
private String sex;
private int age;
private String subject;
private String mark;

public Student() {

}

public Student(String name, String sex, int age, String subject) {
super();
this.name = name;
this.sex = sex;
this.age = age;
this.subject = subject;
}

public String getMark() {
return mark;
}

public void setMark(String mark) {
this.mark = mark;
}

@Override
public String toString() {
return name + "," + sex + "," + age + "岁," + subject + "," + mark;
}

}

package com.bao.test;

import sun.print.resources.serviceui;

public class StudentTest {

public static void main(String args[]) {
Student student = new Student("王萍", "男", 19, "英语");
student.setMark("优秀");
System.out.println(student);
}
}

输出结果:王萍,男,19岁,英语,优秀

网友(3):

你又来了啊?刚才我帮你写了,可是被人抢先一步,我不帮你写了,你等那位大哥吧。

网友(4):

没听懂你什么意思 说清楚点嘛