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

2024-11-18 01:46:08
推荐回答(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:

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