就是想问。在定义的函数里边如何访问到set()中的score;

public class StudentTestDrive {
static void primitive(int x) {
x = x * 10;
System.out.println("x*10=" + x);
}

static void quoter(Students newstudent) {
newstudent.setScore();//编译器说是找不到符号。
    newstudent.setScore() = newstudent.setScore() * 3;
    System.out.println("newstudent.score * 3 =" + newstudent.setScore());
}

public static void main(String[] args) {
    int a = 9 ;
    Student onestu = new Students();
    onestu.setScore(newscore) = 60;
    primitive(a);
    System.out.println("a have been changed " + a);
    quoter(onestu);
    System.out.println("onestu.setScore() has been changed" + onestu.setScore());

}

}

Student 类
public class Students {
private String name;
private int score;

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public double getScore() {
    return score;
}

public void setScore(int newscore) {
    if(newscore > 0){
    score = newscore;
    }

}
void studentthought(){

    System.out.println("I WANT TO BE A GOOD STUDENT !");
}

}

这不是有个get()方法吗图片说明

我是初学者,你是说定义的函数不能访问set,但是可以访问get();是吗?

你调用setScore时没有传参数

已经解决了。谢谢大家。